我想打开画廊的特定文件夹。我知道打开图库并从中选择任何图像的代码。但我只想在默认图库中打开文件夹。 还有另一种方法可以手动访问该图像并通过 Activity 中的 vreat gallery 显示它。但我想默认打开。
我试过这个。但显然不起作用。
Intent intent = new Intent();
intent.setType("image/myFolder/*");
intent.setAction(Intent.ACTION_VIEW);
startActivity(Intent.createChooser(intent,
"Select Picture"));
有人可以帮忙吗?
提前致谢
最佳答案
我认为这可能对某些人有帮助... 因为我找到了解决问题的办法。
private ArrayList<File> m_list = new ArrayList<File>();
String folderpath = Environment.getExternalStorageDirectory()
+ File.separator + "folder_name/";
File dir = new File(folderpath);
m_list.clear();
if (dir.isDirectory()) {
File[] files = dir.listFiles();
for (File file : files) {
if (!file.getPath().contains("Not_Found"))
m_list.add(file);
}
}
m_list 包含 folder_name 下的所有文件。
干杯!
关于android - 在Android中访问图库的特定文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6519024/