请各位帮个忙::问如何获取手机sd卡中所有图片的路径
解决了指定文件夹下的图片加载,在模拟器上可以运行,但是在真机上却不行,纠结了很久,求各位朋友指点指点,代码如下::
求教::如何解决在真机不可遍历的问题
//遍历SD卡中某一路径下指定类型的图片
private List<String> getSD() {
it = new ArrayList<String>();
File f = new File(Environment.getExternalStorageDirectory() + "//" + "DCIM/Camera");
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (getImageFile(file.getPath()))
it.add(file.getPath());
}
return it;
}
//指定遍历文件类型
private boolean getImageFile(String fName) {
boolean re;
String end = fName
.substring(fName.lastIndexOf(".") + 1, fName.length())
.toLowerCase();
if (end.equals("jpg") || end.equals("gif") || end.equals("png")
|| end.equals("jpeg") || end.equals("bmp")) {
re = true;
} else {
re = false;
}
return re;
}