【发布时间】:2015-08-26 22:13:45
【问题描述】:
我正在使用下面的代码从 DCIM 内的 Camera 文件夹中获取所有图像并显示在我的应用程序中。但我想在我的应用程序中显示设备上的所有图像,无论它们存储在设备上的什么位置。我该怎么做?
String ExternalStorageDirectoryPath = Environment
.getExternalStorageDirectory()
.getAbsolutePath();
String targetPath = ExternalStorageDirectoryPath + "/DCIM/Camera";
images=new ArrayList<String>();
File targetDirector = new File(targetPath);
File[] files = targetDirector.listFiles();
for (File file : files) {
images.add(file.getAbsolutePath());
}
gallerylist=new CameraGalleryAdapter(getActivity().getApplicationContext(),R.layout.giphy_grid,images);
gridview.setAdapter(gallerylist);
【问题讨论】:
标签: android android-camera android-gallery android-external-storage