How to Show Directories/Folders in Gallery in android?

1k Views Asked by At

I am making an app where first i create directory and then storing the images in that directory. I am able to see these directories (folders and sub-folders) containing images. But in Gallery , they are not visible.

Here is how i am making a directory.

  File filePath = Environment.getExternalStorageDirectory();
        String phNumber[] = // userNumber
        String dir = "/My Main Dir/"+phNumber[0];
        File imageDirectory = new File(filePath, dir);
        if(!(imageDirectory.exists())){
            imageDirectory.mkdirs();
        }

Whenever i saved an image in that directory , m calling this:

getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));

The directory shows after when i restart my phone and wait for a long time. Is there anyway where i can show an immediate effect or so in my gallery.

0

There are 0 best solutions below