Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 07:36:44 GMT

Sponsored Links
 I'm torn between which group to post this too, but since it is for an
application I am working on, I guess I'll stick it here.

So here we go.  I have an application which downloads data onto the
sdcard to be used by the application.  Some of these files are sound
or music files and the music player in android seems to parse these
directories and add these files to the list.  I'd like to somehow
block or hide these files from the music player.  Is there is a way to
do this?

I was thinking it may be possible to name my folder with a period at
the beginning, since linux hides such files.  I'm just not sure if
that is going to hide it from the music player or if there is another
way to handle this.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 07:51:52 GMT


You could have just tried it, and you would have found that that does indeed
have the effect you're looking for.
Alternatively, you can put a file called ".nomedia" in a directory to
prevent the media scanner from scanning that directory.


Sponsored Links

Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 10:06:48 GMT


Could have, assuming I was at my development machine at the time.
Either way, thanks for the info.


Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 13:08:59 GMT

 Just tried it and the sounds are showing up in the music player.  So
much for that idea.  Anyone else  have experience with this?

I guess I can try changing the extension since I pass it the Uri, and
hopefully MediaPlayer and SoundPool don't choke.  I just have quite a
few files and would hate to have to check them and rename them from
within the app or have the users re-download the new data.

Suggestions welcomed.



Hiding media files from Music Player

by nEx.Software » Tue, 28 Apr 2009 14:33:13 GMT

 A quick look shows at the source indicates the MediaScanner omits
files that begin like "._" or are like "Folder.jpg",
"AlbumArtSmall.jpg", "AlbumArt_{...}_Large.jpg" or "AlbumArt_{...}
_Small.jpg". But it all seems to be based on filename. Of course
there's a native method in there "processDirectory" that I don't
understand because I don't understand c++. Maybe that's supposed to
weed out certain folders/files? Of course, I don't know if this helps
at all but I'll let you decide if it does. Almost looks like changing
the extension will be the answer as that appears to be very important
in determining whether the MediaScanner picks up the file.
Good luck, will be interested to see the final answer on this one.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 23:32:16 GMT


The native method will skip any folders whose name starts with a period.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 23:34:11 GMT

 You put the files in a folder whose name starts with a period, and they
still show up in the music app?
Are you sure it's not the old files in the old location that are still
showing? Can you check that there are actually entries in the media database
whose path (the _data column) includes a folder that starts with a period?


Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 23:52:18 GMT


I actually renamed the folder programmatically and verified that it
was indeed renamed.  Files in media player still show up and play.

I can check the DB once I get home and I am at my development machine,
unless there is an easy way to check that information directly within
the phone.  Music player does not provide file details, unfortunately.


Hiding media files from Music Player

by clark » Wed, 29 Apr 2009 10:20:46 GMT


Actually that did help.  I'm a C++ guy so taking a look at
MediaScanner.cpp in thre OpenCORE git provided some insight.

Based on the code the scanner 'should' omit folders that begin with a
period or folders which contain a file named .nomedia.

A little digging revealed sounds on my sdcard that were similar to the
ones I was using in my app.  Between that and users still complaining
about sounds showing up in their music player I assumed the folder
renaming did not work but indeed it did.

Placing a file named .nomedia in the folder works great as well.


Other Threads

1. How to mute Hero ?

Sorry silly question :D

Lagi meeting nih.. Hero bunyi mulu :((

Gmana cara mute-nya ya?



Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:

2. Application using service in different project

I want create a service and that other application use this service.
I want that the other application is in a different project that the

It is possible?
If is possible somebody can show me a sample code.

Thanks in advance.


3. android 1.5 and 1.6 versions of SDK sitting side by side...

4. launch app from an app

5. GPS applications for turn by turn navigation?

6. Android API

7. Availability of Android Development phone