Wednesday, April 8, 2015

Android - How to browse Android Emulator SQLite Database


In this tutorial, we will show you how to browse android emulator SQLite database.
You need these tools! Trust me, if you not able to browse data that you have saved you will spend a lot of time and killing your brain cell to debug line by line. That is a nightmare :).

How to browse Android Emulator SQLite Database

There are 2 ways to browse SQLite database in Android Emulator
  • View from the eclipse with a plugin tool.
  • Pull data out from eclipse and view data with SQLite database Browser, (There are some other tools also can view the database like SQLiteSpy.)

  • View from the eclipse with a plugin tool
  1. Download com.questiod.sqlitemanager.jar and save into “X:\…\eclipse\dropins” folder, Eclipse update manager will install any jar in this directory, if you like to uninstall it just simply delete the jar file.
  2. Restart Eclipse.
  3. Navigate menu to Windows>Show View>Other>Questiod SQLite Manager
    Show View
  4. Find the DDMS icon, and click on it. The SQLite manager tools should be installed and it will look like below
    SQLitemanager
  5. So, Let’s try it!
  6. In this tutorial,
    We will use com.android.providers.email database that available in the emulator as testing target and it’s locate in data/data/com.android.providers.email/databases/EmailProvider.db. Click on the File Explorer. You should see something like this. Please take note you need a “db” extension file or else the tool will not enabled.
    File Explorer
  7. Click on the Open File in SQLite Manager… icon
  8. You will see the image like below for viewing all tables and data.
    Browse android emulator database
  9. Click on the Browse Data tabs, and choose a table named android_metadata, you will see data in this table.

  • Pull data out from eclipse and view it with SQLite database Browser.
  1. Click on DDMS icon. Icon in the highlight circle is for import file from and to emulator, the left icon is export and right icon is for export. Click on the left icon to save it to the desktop.
    Pull data
  2. In case you can’t see DDMS as showed in image. You can bring it out by going to Window > Open Perspective > DDMS
  3. Use SQLite Browser, Click Open Existing Database file and then select EmailProvider.db from where you save in step 1.
  4. And you will see image like below. This tool allow you to insert, update data and write query in Execute SQL tab.
    Pull data

Tips:
1. When you create your database, please make sure create with “db” extension. i.e. instinctcoder.db.
2. Personally i preffered the 2nd method as it allow you to insert, update data and select data.
3. During development, sometimes you need to run in debug mode(F11) in order to get latest data.

Source:  http://instinctcoder.com/how-to-browse-android-emulator-sqlite-database/

0 comments:

Post a Comment