views:

51

answers:

1

I'm placing the file '.nomedia' into a folder in order to avoid Android's MediaScanner from detecting the media files in the folder. I need to copy this folder (including '.nomedia') from the APK's assets to the SD card (so other apps can make use of these media files, etc.). When I package the APK in Eclipse, it doesn't package the '.nomedia' file. Presumably it's detecting it as a hidden file. Any ideas how to fix this? Is there a secret aapt flag I can use? I'd like to avoid copying the folder and then manually creating a '.nomedia' folder, if possible.

A: 

Assets get compiled into the application, you can't see them through file browser. You'd have to access this folder from code and then copy it to the file system when the app is first launched or installed. Take a look at this example, it talks about a database file, but in general you want to do the same thing for ANY file you put in assets and want to move to the file system:

http://www.helloandroid.com/tutorials/how-have-default-database

Ricardo Villamil
I've been successful at copying files in general from the assets folder to SD. What I have had trouble with was particularly the '.nomedia' file which inexplicably seems to be absent from the APK. It seems that at compile time, .nomedia is simply not being included in the final APK while all the other files are indeed included.
ChaimKut