Friday, 16 October 2020

Create a folder like WhatsApp Images, WhatsApp Videos in Albums or Gallery

My requirement is to show directory under Gallery/ Albums, creating a directory in the following way does not full fill my requirement...

 File rootPath = new File(Environment.getExternalStorageDirectory(), "directoryName"); 
 if(!rootPath.exists()) {
                rootPath.mkdirs();
            }

            final File localFile = new File(rootPath,fileName);

by using this code i can see the folder by using "file mangaer" with the path... "deviceStorage/directoryName" but the folder is not visible under Gallery or Albums

for directory creation i tried the following ways too...

 1)File directory = new File(this.getFilesDir()+File.separator+"directoryName");

 2)File directory = new File (Environment.getExternalFilesDir(null) + "/directoryName/");

3)File directory = new File(Environment.
  getExternalStoragePublicDirectory(   
 (Environment.DIRECTORY_PICTURES).toString() + "/directoryName");

but no luck, please help me friends thanks in advance.



from Create a folder like WhatsApp Images, WhatsApp Videos in Albums or Gallery

No comments:

Post a Comment