gregm
gregm

Reputation: 12159

How do I find the database file on an Android virtual device?

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 .

Upvotes: 3

Views: 9187

Answers (3)

Pulkit Sethi
Pulkit Sethi

Reputation: 2311

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/

Upvotes: 1

MannyNS
MannyNS

Reputation: 4701

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.

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006664

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.

Upvotes: 4

Related Questions