首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

从存储卡中读取带特定后缀的资料

2012-07-03 
从存储卡中读取带特定后缀的文件从sd卡中找出:后缀为.vcf的所有文件:? ? public static File[] getcontact

从存储卡中读取带特定后缀的文件

从sd卡中找出:

后缀为.vcf的所有文件:

? ? public static File[] getcontactList() {

? ? ? ? File root = new File(getBackUpPath());

? ? ? ? File[] l = root.listFiles(new FilenameFilter() {

?

? ? ? ? ? ? @Override

? ? ? ? ? ? public boolean accept(File dir, String filename) {

? ? ? ? ? ? ? ? if (filename.endsWith(".vcf")) {

? ? ? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? });

? ? ? ? return l;//l为file数组。

? ? }

?

? ? public static String getBackUpPath() {

? ? ? ? return "/mnt/sdcard";//在指定目录中查找。

? ? }


热点排行