我想要实现一个图库。在主视图中,我想查看图像文件夹列表。单击网格项应该打开网格与相关文件夹的图像
答案 0 :(得分:0)
这是一些代码,我希望它有用:
// Get directory where camera images are stored
String state = Environment.getExternalStorageState();
File imageDir = null;
if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
File externalDir = Environment.getExternalStorageDirectory();
imageDir = new File(externalDir, "DCIM/camera");
if (!imageDir.exists())
/* Handle error */;
}
// List filenames of images
String[] fileNames = imageDir.list();