Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packaging "hidden" asset files

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.

like image 752
ChaimKut Avatar asked Jun 09 '10 14:06

ChaimKut


People also ask

What are the hidden files in home directory?

Files whose names begin with ``. '' (dot) are hidden from view in a normal directory listing. Certain programs, such as mail and your shell, create hidden files to avoid cluttering your home directory with unnecessary files.

What is an asset folder?

Global Asset Folder Assets are non-post files in the source folder, such as images, CSS or JavaScript files. For instance, If you are only going to have a few images in the Hexo project, then the easiest way is to keep them in a source/images directory. Then, you can access them using something like ! [](/images/image.


2 Answers

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.

like image 162
g4m3c0d3r Avatar answered Sep 19 '22 22:09

g4m3c0d3r


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

like image 34
Ricardo Villamil Avatar answered Sep 19 '22 22:09

Ricardo Villamil