I'm placing the file '.nomedia' into a folder in order to avoid Android's开发者_如何学JAVA 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.
I know this is several years after the question was asked, but I ran into this question searching for the same issue myself, and discovered the solution that worked for me so I thought I would post it:
In your "ant.properties" file for your project (create a new one if you don't have it) add these two lines:
# DO NOT ignore the .nomedia file in the assets directory!
aapt.ignore.assets="!.svn:!.git:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
This will remove the ".*" from the default exclude list, and thus .nomedia will now be included in your assets directory inside your .APK.
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
精彩评论