views:

989

answers:

3

My plan is to prepopulate a database on a virtual device and then include database in the distribution of my app.

However, I can't find the database file.

Is it on my hard disk some where? How do I get it?

I tried connecting using adb, I did an "ls" and then got really scared by this obscure list of directories:

sqlite_stmt_journals cache sdcard etc system sys sbin proc init.rc init.goldfish.rc init default.prop data root dev


Even when I cd over to /data/data/your.package.here/databases I still do not have access to the actual database file. I can't use sqlite3 or do a pull on it. Is there a way to change permissions?

This works fine on my emulator, but fails on the actual device adb pull /data/data//databases/mydb.db .

+1  A: 

It should be in /data/data/your.package.here/databases, where your.package.here represents the package associated with your application, as defined in your AndroidManifest.xml file.

CommonsWare
I get access denied when I try to access that with adb. How to I access the file?
gregm
If your application is compiled in debug mode, AFAIK, you can do an adb pull straight to the path to your database file. You cannot, though, view intermediate directories (e.g., /data) via ls. And, if you are compiled in production mode, I suspect you cannot even get to the database.
CommonsWare
A: 

If you want to navigate to your database (which is located /data/data/your.package.here/databases), make sure you are a root user while navigating shell. To do so, type "su" once you enter the command prompt. When you are a root user, you can navigate wherever you want.

MannyNS
A: 

The blog post below gives a good solution of how to find and access your database. The post talks about using busybox, which provides useful utilities at the command line, to find your database and gives a few useful examples on how to use sqlite3 to access the DB and tables.

http://davanum.wordpress.com/2007/12/11/android-how-to-poke-around-the-sqlite3-databases/

Pulkit Sethi