Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Android emulator store SQLite database?

Tags:

android

sqlite

I'm working on an Android application that stores data in a SQLite database. My question is, where does this database file get stored on the filesystem when you're using an emulator?

I have seen that it's stored in

/data/data/package_name/databases

but I need to know where on my local machine's hard drive that actually maps to. The database persists on multiple runs of the emulator, even after having shut down the machine, so it can't just reside in RAM...

like image 218
I82Much Avatar asked Oct 02 '09 17:10

I82Much


People also ask

Where does the Android emulator store files?

The android tools create an . android folder in your users home folder. This folder contains an avd folder in which a separate folder for each virtual device exists. In each of this folders a file called sdcard.

Where is Android SQLite database stored?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.

Where will Android databases be stored?

Just like files that you save on the device's internal storage, Android stores your database in your app's private folder.


2 Answers

An update mentioned in the comments below:

You don't need to be on the DDMS perspective anymore, just open the File Explorer from Eclipse Window > Show View > Other... It seems the app doesn't need to be running even, I can browse around in different apps file contents. I'm running ADB version 1.0.29


Or, you can try the old approach:

Open the DDMS perspective on your Eclipse IDE

(Window > Open Perspective > Other > DDMS)

and the most important:

YOUR APPLICATION MUST BE RUNNING SO YOU CAN SEE THE HIERARCHY OF FOLDERS AND FILES.

Then in the File Explorer Tab you will follow the path :

data > data > your-package-name > databases > your-database-file.

Then select the file, click on the disket icon in the right corner of the screen to download the .db file. If you want to upload a database file to the emulator you can click on the phone icon(beside disket icon) and choose the file to upload.

If you want to see the content of the .db file, I advise you to use SQLite Database Browser, which you can download here.

PS: If you want to see the database from a real device, you must root your phone.

like image 136
rogcg Avatar answered Oct 26 '22 00:10

rogcg


The filesystem of the emulator doesn't map to a directory on your hard drive. The emulator's disk image is stored as an image file, which you can manage through either Eclipse (look for the G1-looking icon in the toolbar), or through the emulator binary itself (run "emulator -help" for a description of options).

You're best off using adb from the command line to jack into a running emulator. If you can get the specific directory and filename, you can do an "adb pull" to get the database file off of the emulator and onto your regular hard drive.

Edit: Removed suggestion that this works for unrooted devices too - it only works for emulators, and devices where you are operating adb as root.

like image 29
Eric Mill Avatar answered Oct 25 '22 22:10

Eric Mill