0

We are building a camera app that saves photos in a specific folder in the gallery. And we have to open the folder of our app in the gallery using an intent. We are using this code however it shows all folders.

View.OnClickListener goToGallery = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setType("image/*");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
};
giroxasmnl
  • 131
  • 1
  • 3
  • 14
  • Possible duplicate of [How can I display images from a specific folder on android gallery](http://stackoverflow.com/questions/13418807/how-can-i-display-images-from-a-specific-folder-on-android-gallery) – Mohamed Nov 01 '15 at 03:44

2 Answers2

0

To open gallery I use this intent.

public static final int RESULT_GALLERY = 0;

Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

startActivityForResult(galleryIntent , RESULT_GALLERY );

Shashank Udupa
  • 2,173
  • 1
  • 19
  • 26
0

Try this code. It will retrieve view pictures under storage/emulated/0/Pictures/MyAppPics You can change the file path according to your directory path.

File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File f = new File(sdDir, "MyAppPics");

Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.withAppendedPath(Uri.fromFile(f), "/MyAppPics"), "image/*");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
srv242
  • 105
  • 10
  • For this to work, is it mandatory to have images in storage/emulated/0/Pictures? My images are in a folder in internal memory. And this solution doesn't work for it. – Pranav Mahajan Apr 15 '17 at 11:37