Access Specific folder of gallery in Android

2019-05-12 22:59发布

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条回答
女痞
2楼-- · 2019-05-12 23:51

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!!

查看更多
登录 后发表回答