Reputation: 61
I want to create some hidden folders like photo hide app and hide the selected image from gallery or camera to selected hidden folder.i googled a lot but i couldn't find any solution.please find me a solution.. Thanks in advance
Upvotes: 6
Views: 12592
Reputation: 170
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
}
Upvotes: 2
Reputation: 1010
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..
To create hidden folders or files follow Hamid S. instructions:
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/.Image/");
file.mkdirs();
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.
Upvotes: 9
Reputation: 9700
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();
Upvotes: 3
Reputation: 167
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.
Upvotes: 0
Reputation: 6142
try function like..
public static void hideFile(File file)
{
File dstFile = new File(file.getParent(), "." + file.getName());
file.renameTo(dstFile);
}
Upvotes: 1