banner



How To Create A Hidden Folder

5 Answers 5

my requirement is when i add files to hidden folder those should not be shown in gallery but hidden folders and files should be shown only in my application..

  1. To create hidden folders or files follow Hamid S. instructions:

                      File file = new File(Environment.getExternalStorageDirectory().getPath() + "/.Image/"); file.mkdirs();                                  
  2. To prevent the eg. gallery app from showing pictures within /.Image/, create the additional (empty) file .nomedia

This prevents media scanner from reading your media files and providing them to other apps through the MediaStore content provider. However, if your files are truly private to your app, you should save them in an app-private directory.

answered Aug 7 '14 at 1:06

To create hidden folder or file use Dot (.) that folder or file name.

Suppose, you want create a folder named Image which will be hidden then create as follows...

                File file = new File(Environment.getExternalStorageDirectory().getPath() + "/.Image/"); file.mkdirs();                              

answered Apr 25 '14 at 11:36

2

  • thanks for your kind reply. now i am able to make hidden folders and files but my requirement is when i add files to hidden folder those should not be shown in gallery but hidden folders and files should be shown only in my application..

    Apr 25 '14 at 12:29

  • this code is working fine in all devices except android 4.4 devices.In android 4.4 devices sdcard (.)folders also visible how can we hide these (.)folder in android 4.4

    Apr 30 '14 at 10:53

try this code,

              String iconsStoragePath = Environment.getExternalStorageDirectory() + "/.NewFolder";     File sdIconStorageDir = new File(iconsStoragePath);     if(!sdIconStorageDir.isDirectory()){         sdIconStorageDir.mkdirs();//create storage directories, if they don't exist     }                          

answered Jul 5 '17 at 11:41

try function like..

                public static void hideFile(File file) {         File dstFile = new File(file.getParent(), "." + file.getName());         file.renameTo(dstFile); }                              

answered Apr 25 '14 at 11:36

3

  • thanks for your kind reply. now i am able to make hidden folders and files but my requirement is when i add files to hidden folder those should not be shown in gallery but hidden folders and files should be shown only in my application..

    Apr 25 '14 at 12:31

  • Its totally new question..post new one,,And if My answer solve your problem you can accept it..

    Apr 25 '14 at 12:34

  • this code is working fine in all devices except android 4.4 devices.In android 4.4 devices sdcard (.)folders also visible how can we hide these (.)folder in android 4.4

    Apr 30 '14 at 10:53

In Android, as well as in most Linux environments, you can create a hidden folder simply by adding a '.' to the front of the folder name. For example, the folder '.MyFolder' would be hidden.

answered Apr 25 '14 at 11:36

3

  • thnx for your reply,how to get unhide/visible the folders and files list in my application and those files and folders should not be visible in device gallery

    Apr 25 '14 at 12:34

  • By default any hidden files/folders will not be viewable in the gallery. As far as globally unhiding the folder, you would just have to rename it without the '.' in front. If you want to propagate your app with images in the hidden folder, you could just save the path to the hidden folder in SharedPreferences for later use after creating it. As long as you have the proper permissions for accessing files, you will be able to see the files in these saved paths in your app.

    Apr 25 '14 at 12:41

  • this code is working fine in all devices except android 4.4 devices.In android 4.4 devices sdcard (.)folders also visible how can we hide these (.)folder in android 4.4

    Apr 30 '14 at 10:54

Not the answer you're looking for? Browse other questions tagged android image file filesystems sd-card or ask your own question.

How To Create A Hidden Folder

Source: https://stackoverflow.com/questions/23291852/how-to-create-hidden-folders/25172699

Posted by: parentdights.blogspot.com

0 Response to "How To Create A Hidden Folder"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel