I started to look into using databases with Android for my first application and searching high and low over the internet, this is what I’ve compiled. One may ask where does the sqlite database of the emulator is being stored on the hard disk of your PC, well, the files ystem of the emulator does not map to a directory on your hard drive. It’s stored as an image.
Sqlite database on your Android emulator
1.Create it in onCreate() when your app first launched:
According to Using Databases | Android developer:
The recommended method to create a new SQLite database is to create a subclass of
SQLiteOpenHelperand override theonCreate()method, in which you can execute a SQLite command to create tables in the database
There’s a sample coding on how to populate the DB programmatically here at the Data Storage| Android developer.
2. Create the sqlite database on your PC and adb push it to your emulator.
- Use the Android Debug Bridge (adb) pull/push to retrieve a copy of the database on your Android emulator, populate it and put it back on the emulator.
- Fire up your emulator.
- Open up your command shell (Start -> Run -> type in cmd):

Your database will be stored in data/data/<package name>/databases/<db name of your choice>
The full command as the screenshot above is:
adb pull data/data/com.chien.programmersquote/databases/quote local_database
‘quote’ is the DB that is stored on the emulator and obviously local_database is the DB file name I will be downloading my database to at C:\users\Sted\
After that you could manipulate the DB using one of the tools available freely, namely the firefox addon, Sqlite Database Browser, SqliteSpy.
In the emulator you can access these database files directly; when connecting to a real phone however you will need root access to access the database files directly.
3. Import/Export via DDMS from Eclips
Inside Eclipse while the emulator is running, you can see your file hierarchy by going to Window -> Show View -> Other.. -> Android -> File Explorer ( or just click on the DDMS icon)
It took me some time to figure out the there are 3 buttons here on the DDMS page that serves as adb pull, adb push and delete file. Navigate to your database at data/data/<package name>/databases/ and just click on the button to either download / upload / delete the database.
Hope it helps. Ways described above are just generally some ways to deal with populating the database on your emulator for testing purposes.



9 Comments
thank you very much.
Before reading this i was pushing and pulling files from the command line and it was such a waste of time.
Sometimes so small and unnoticeable things can be of immense importance.
thanks again for this post.
I am new for Android. I have created one app and local database using sqlite database browser. My database path on eclipse is MyAppName/assets/dbfile. I tried your mentioned step 3 to push this database into my emulator. My question is when I select path from DDMS like data/data// I see no databases folder in it, so does this databases folder is created default or I need to create it?
The database should be in /data/data//databases/
Your database should be there once you import it ( via DDMS or adb push ).
Note that this is only for testing purposes on local environment.
just for correction. /data/data/*name of your package*/databases/
for the sake of future viewers. XD
Hey Reshma, you can create database once by running your application containing code for creating the database. As soon as you run that, database will be created and you will get database folder in data/data/package_name/
Gracias amigo. This is very helpful information.
-Nate
really its east than cmd method…i got it easy .. thanks:)
Simple things may help great
Thanks for info…. but my database disappears each time I close and re-open the AVD so I have to re-create it each time. I used SQLite Manager add-on for Firefox to create it. Am I doing something wrong? Also if I create the database in the /data/data/ package name/databases/ on the emulator, will it move to the SD card when it ids enabled in the manifest on loading to an actual device?