Search code examples
androidandroid-studiogalleryandroid-image

Android display images from a specific folder


I need to display the images that are in a specific folder on the SD card. I want to do it with a button and display the gallery. But, I don't know how to do it. I found some solution like this, but that solution didn't work for me:

public void openFolder(View view)
{
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
            +"/pictures/miscursos/");
    intent.setDataAndType(uri, "image/jpeg");
    startActivity(Intent.createChooser(intent, "Open folder"));
}

This just opens all the images, but not the folder that I want.


Solution

  • The above code will only opens the folder. You have to use GallerView or GridView with the help of Adapter you can set images to ListView or GridView. You have to give correct path in-order to open the folder you want. GridView loading photos from SD Card - refer this link