I am developing an Android app that makes use of an SQLite database. Every now and then I want to see what is the state of my app’s database to make sure things are being stored the way I expect. To do this you need to connect to your emulator using an adb shell.

Make sure your emulator is running and run this command to get a terminal to the emulator:

1
adb shell

You will be presented with a prompt similar to this one:

1
root@android:/ #

Then go to the folder where the database for your app lives:

1
cd /data/data/<Your app, something like com.mydomain.myapp>/databases/

There you will find your database files. You can then use the SQLite client to inspect your database:

1
sqlite3 mydb.db

I am very familiar with MySQL, so the first thing I tried was to run SHOW TABLES. This command doesn’t exist in SQLite, so I had to find the equivalent:

1
.tables

Notice that there is no semicolon at the end of the line. For some reason the command doesn’t work if you add a semicolon. Then I tried DESCRIBE table, but it didn’t work again. The closest replacement I found was:

1
.schema mytable

which will return the create statement for the table.

Select statements are pretty similar to MySQL, so if you want to see all the contents of a table you can use:

1
SELECT * FROM mytable;
[ android  debugging  linux  mobile  ]
Passing Arguments To a Java Binary Ran With Bazel
Get arguments used to start a java process
Getting PID for Java Process
Installing Ubuntu on an old computer - Broken graphics
Using lsof to find who is using a file or socket