user291701 user291701 - 3 months ago 21
Android Question

Stop images on sd card from showing up in gallery?

I keep some png files on the user's sd card. Some users report that these images are showing up in their gallery application. Sounds like the gallery implementation on some devices search out any image files they can find on the sd card and show it in the gallery. Is there a way to tell the system not to include these images in the gallery? It's just an annoyance to the users.

Thanks

Answer

You can hide individual files from the gallery with a . prefix. For example .myimage.png

I'm not sure what version dependencies the above has and it doesn`t work with some third-party picture tools like the Gallery.

You should add a file named .nomedia into the directory where your images are. You may need to eject and re-insert the SD card before the images disappear from gallery (or otherwise trigger the media scanner) after creating this file on a phone that the Gallery has already picked up the files in the Gallery.

I think the .nomedia option is the best solution, although again, third party tools may not respect the .nomedia flag.