Android: Hide your application's media files from the Gallery App

If you have a media heavy application it is very likely that you store the image, sound or video data on the sd-card, since it gives you a lot more space than bundling everything with the application. Also, it enables you to dynamically add, remove or modify your media data.


However, the problem that comes with it is, that all your media is public now and can be read by other applications, e.g. the Gallery App, which scans the whole sd-card for image files. To prevent other applications from scanning and displaying your media files, you can simply add an empty file called .nomedia in the root folder of your media data.

From the official Android documentation:
Name of the file signaling the media scanner to ignore media in the containing directory and its subdirectories. Developers should use this to avoid application graphics showing up in the Gallery and likewise prevent application sounds and music from showing up in the Music app. 

3 comments:

  1. Thx. sometimes the solution is nice and easy :)

    ReplyDelete
  2. Thanks Stefan! I always wondered where and how i can customize this. Practically, no big application currently uses this...

    ReplyDelete