Reputation: 796
I am developing an android application where it will select some photos from the gallery and hide them,
i am able to select particular picture from gallery and store it in my app and delete it from gallery,but a person can see those pictures if he opens my app folder in sdcard ,so how do i store them such that even if a person checks my sdcard then he should not be able to detect those pictures ?
Upvotes: 9
Views: 15927
Reputation: 181
If you want to prevent Gallery from showing images from your app's folder, you can put a file named .nomedia in that folder.
If you want to hide the folder from apperaring in say, a File Manager, then ensure your folder starts with a period (.). For example, if the folder is called myfolder, it should be created as .myfolder
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File(sdCard.getAbsolutePath()
+ "/.myFolder" );
Upvotes: 1
Reputation: 27748
If you want to prevent Gallery from showing images from your app's folder, you can put a file named .nomedia
in that folder.
Source: https://stackoverflow.com/a/6713863/450534
If you want to hide the folder from apperaring in say, a File Manager, then ensure your folder starts with a period (.). For example, if the folder is called myfolder, it should be created as .myfolder
Source: https://stackoverflow.com/a/5878270/450534
Please note, that a user can change the settings of the File Manager to show hidden files and folder. For that, there is no solution.
Upvotes: 8
Reputation: 2779
The only secure way to do this is to encrypt the image data yourself and remove the original files, leaving only your application able to decrypt the files.
Take a look at How to encrypt file from SD card using AES in Android? to see how this can be done.
As an additional step, you can also use any number of the other answers to hide the encrypted files
Upvotes: 11
Reputation: 2236
Use your sd card folder path as
Environment.getExternalStorageDirectory().toString()+context.getPackageName+"//data//data//"+"(.folderName)";
this will provide you maximum security to your images, if user phone is not rooted this path is safe from all aspects.
Upvotes: 0
Reputation: 16152
See this . that are perform with one step more. they are hiding data as well as folder also.
How to hide a folder in sdcard in android
Upvotes: 0