Access Specific folder of gallery in Android

大兔子大兔子 提交于 2019-12-22 10:48:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!