How to pull SQLite file out from Android emulator with Eclipse
Question: I am having an Android project and want to save the SQLite database file I have created in the project. I’d like to use it in another Android and iPhone projects. I googled for it but could not find a simple guide. Where is that file? I can’t find the so called /data/data/package_name/databases folder on my Mac many pros refer to. I am a beginner with Eclipse and Android SDK.
Answer: When you add an SQLite database to your Android project the Eclipse or filesystem of the emulator does not create or map to a folder on your hard drive.
1. Select DDMS perspective on your Eclipse as this screenshot shows (Window -> Open Perspective -> DDMS):
2. On the main pane chose File Explorer tab. On the folder list navigate to /data/data/yourapp/databases folder.
3. Select your SQLite file as shown in this picture:
4. Click on the Pull icon to “export” the database file to your file system.
5. Select destination folder and file name, and Save it.
6. You can switch back to your Java code by selecting Windows -> Open Perspective -> Java menu.
7. Alternatively you can pull your database file from an Android device or emulator to your harddisk using adb’s pull command line option in Terminal.
Notes:
– You’ll find an android_metadata table in the database file. It has a locale TEXT field set to “en_US”. The INTEGER PRIMARY KEY id field of your table(s) is likely named as “_id”.