//查找文件夹下图片的数量\
private int getFiles(String string){
int i=0;
File file = new File(string);
File[] files = file.listFiles();
for (int j = 0; j < files.length; j++) {
String name = files[j].getName();
if (files[j].isDirectory()) {
String dirPath = files[j].toString().toLowerCase();
System.out.println(dirPath);
getFiles(dirPath + "/");
} else if (files[j].isFile() & name.endsWith(".jpg") || name.endsWith(".png") || name.endsWith(".bmp") || name.endsWith(".gif") || name.endsWith(".jpeg")) {
Log.d(TAG1,"FileName===" + files[j].getName());
i++;
Log.d(TAG, "getFiles:i "+i);
}
}
return i;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19