Access specific gallery folder

Asked

Viewed 998 times

0

I wonder if it is possible to access a specific folder in the gallery, because I take photos with my app and saved in his folder there in the gallery, but I wanted that when the user went to select an image through my app, that he only had access to this folder of the app. Below code that access to gallery.

 public void loadImagefromGallery(View view) {
    Intent galleryIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(galleryIntent, SELECIONAR_IMAGEM);
}

2 answers

0

What you want is a gallery filter, for the user to access only certain photos (those of your app) through the native gallery app, right?

There’s no way. I’ve gone after it and I’ve spent a lot of time trying to find a solution. You can open a single photo with the native image viewer, and nothing else. There is no way to open a photo array with it, for example, or open the native gallery with a filter.

The only solution is to create your own gallery. It’s not very complex. You will need to go after how to manage folders and files and how to use gridview and, most importantly, an imageloader to not crash Android(recommend Glide -- https://github.com/bumptech/glide). Remember to stitch before the folder name to prevent Android from pinning these photos to the native gallery. (/. photos instead of /photos)

0

Use that code:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
    + "/myFolder/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));

Altering the myfolder pro directory name you created.

  • Thanks for the reply! But I tested and not accessed the images of my app, I put the name of the folder that was created but did not work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.