问题
I want to open specific folder of gallery. I know the code to open gallery and choose any image from that. But i want to just open folder in a default gallery. There is another way to manually access that images and show it by vreating gallery in activity. But i want to open in default.
i tried this one. But obviously not working.
Intent intent = new Intent();
intent.setType("image/myFolder/*");
intent.setAction(Intent.ACTION_VIEW);
startActivity(Intent.createChooser(intent,
"Select Picture"));
Anyone can help?
Thanks in advance
回答1:
I think it may help somebody... As i have found solution to my problem.
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 contains all the files under folder_name.
Cheers!!
来源:https://stackoverflow.com/questions/6519024/access-specific-folder-of-gallery-in-android