Android Emulator: How to access the sqlite database of an app

This is an example of how to access the sqlite database of an Android app running on an emulator.

Make sure you have the android adb tool on your PATH.

Run this command in the terminal: adb version If you have adb on your path, it should show something similar to this:

Android Debug Bridge version 1.0.31

If not, follow this guide: Adding the adb tool to the terminal for easy access.

Accessing the SQLITE database

  1. Open a new Terminal window.
  2. Enter adb shell
  3. Navigate to the folder where your apps databases are:
    cd /data/data/<your app package name>/databases/
  4. Type ls to see which database files are present.
  5. Open a database file with the sqlite3 tool: sqlite3 database-name.db
  6. You can now browse around the database, using the different supported commands.
    To see all commands, type .help
    To list all tables in this database, type .tables To list all rows in a table, type  SELECT * FROM tablename;
  7. When you are done browsing the database, type .exit to return from the sqlite3 tool.

There are a lot of options with the sqlite tool, so I suggest you visit the sqlite documentation for more sqlite commands and examples.

comments powered by Disqus