views:

51

answers:

2

Where are my assets being installed to?

I utilize an assets folder in my new app. I have two files in the folder. When I install my app on the emulator, I cannot access my assets, and furthermore I cannot see them on the emulator filesystem.

Extracted my apk and confirmed the assets folder exists:

$ ls -ltr assets/
total 16
-rw-rw-r--. 1 brad brad 1050 2010-05-20 00:33 schema-DashDB.sql
-rw-rw-r--. 1 brad brad 9216 2010-05-20 00:33 dash.db

On the emulator, no assets folder:

# pwd
/data/data/com.gtosoft.dash
# ls -l
drwxr-xr-x system   system            2010-05-20 00:46 lib
# 

I just want to package a pre-built database with my app and then open it to obtain data when needed.

Just tried it on my Moto Droid, unable to access/open the DB, just like the emulator:

DBFile=/data/data/com.gtosoft.dash/assets/dash.db

Building the DB on the fly from a schema file is out of the question because its such a slow process (about 5-10 statements per second is all I get for throughput).

A: 

If you use the AssetManager you just specify the path to the asset relative to the assets folder.

[...]
Resources res = this.getResources( );
AssetManager assetMan = res.getAssets( );

BufferedReader buff = new BufferedReader( new InputStreamReader(
        assetMan.open( "dash.db" ) ), 8192 );

[...]
Volker Voecking
So considering my goal is to open the database and use it, you're suggesting I open the DB file and copy it somewhere? Where would I copy it to? thanks.
Brad Hein
+1  A: 

Your assets and resources get compiled into the application, you can't see them through the file system, you can only access them through code as Volker suggested. If you need to deploy a DB with your app, check this post:

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

Ricardo Villamil
Direct hit. Thank you!
Brad Hein