9

I know how to programatically get a gallery image (one by one).

Now that the gallery is organised folderwise

Is there a way to select and get the path of a folder in the gallery view...

alt text

Abhishek Susarla
  • 578
  • 1
  • 6
  • 12

3 Answers3

16

With this method you can get the path of the Gallery of your device:

private static String getGalleryPath() {
        return photoDir = Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DCIM + "/";   
    }
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 1
    This works great (+1), but what to do when user has default image/video location set to SD card? How to detect and handle this? – Episodex Oct 13 '15 at 06:10
13

You can get path here but MediaScanner will find every folder on SDCARD with photos.

final String path = android.os.Environment.DIRECTORY_DCIM;
Damian Kołakowski
  • 2,731
  • 22
  • 25
3
String getGalleryPath() {
    File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);

    if (!folder.exists()) {
        folder.mkdir();
    }

    return folder.getAbsolutePath();
}
user1506104
  • 6,554
  • 4
  • 71
  • 89
rayworks
  • 741
  • 9
  • 15