how to hide images from android gallery
Solution 1
Add ".nomedia" file. Did not work? Try the second option.
Save your files to a folder that starts with ".", e.g.,
/sdcard/.myimages/
Solution 2
You can create .nomedia file using this code:
String NOMEDIA=".nomedia";
File Folder = new File(Environment.getExternalStorageDirectory() + "/mydir");
if(Folder.mkdir()) {
nomediaFile = new File(Environment.getExternalStorageDirectory() + "/mydir/"+ NOMEDIA);
if(!nomediaFile.exists()){
nomediaFile.createNewFile();
}
}
Solution 3
I found a simple way(I think so).
Create a folder in 'Android' folder(where data & obb folders are present) and put your media(pics,videos, etc.,) in the folder you've created.
Gallery app ignores that 'Android' folder. Simple :-)
Solution 4
its so late and i know other answers are complete but i think putting .nomedia file makes all pictures in that particular folder hidden :
just change extension of image file programmatically and this way gallery cant detect it as an image . eg if your image is "pic1.jpg" rename it to "pic1.aaa"; and when you want show it again rename it again
Related videos on Youtube
PPShein
Updated on June 04, 2022Comments
-
PPShein almost 2 years
One part of my current project is downloading images from URL then saving to SDCard. But the problem is all of saved images in sdcard is displayed in android gallery page. What I want is "I don't want all of my saved images in android gallery."
-
harikrishnan almost 11 yearsRefer this link[here stackoverflow link][1] [1]: stackoverflow.com/questions/5895992/…
-
-
PPShein almost 11 yearsAdd ".nomedia" in /sdcard/myapps/ folder? And how can I get ".nomedia" file?
-
ozbek almost 11 yearsJust create one, an empty file :)
-
Odaym over 9 yearsThis doesn't work man. Not the first option, not the second option, not even creating the files with prefix "."
-
ozbek over 9 years@Odaym: This doesn't work is a very vague claim. How exactly it is not working? What steps did you take? Did you verify that you are not seeing old cached images?
-
Odaym over 9 yearsDoesn't work meaning that the images still show up after having created the directory with a "." prefix, creating the ".nomedia" file inside that directory and even creating the images with the "." prefix. All after triggering a rescan of media. Saw this too code.google.com/p/android/issues/detail?id=24162
-
nicolas asinovich about 6 yearsits perfect solution!