读书人

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

发布时间: 2012-07-03 13:37:43 作者: rapoo

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

从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";//在指定目录中查找。

? ? }


读书人网 >移动开发

热点推荐