1

I am writing an Android Application with a SQLite Database in the background. This Database gets created by the App, and is stored on the default directory on the device:

shell@android: ls /data/data/com.package.example/databases # 
MyDb.db
MyDb.db-journal

During development I want to test, if the rows are inserted / updated correctly, so I need to take a look on the database. There is a pretty nice tool called SQLite Database Browser (Available for Win, Mac and Linux).

With this tool I can open the database, browse, insert and update the rows and so on... The problem is, that I first need to copy the database from the device to my local machine:

# On Android Shell
# (Cannot pull directly from /data/-directory)
cp /data/data/com.package.example/databases/MyDb.db /sdcard/


# On developing machine
adb pull /sdcard/MyDb.db

Than I have the database on my machine and I can finally open it.

My Question is: Is there a better / quicker way of doing it? Can I somehow directly access the database on the device?

Michael B
  • 1,660
  • 3
  • 28
  • 59
  • If you can write to the database you can read from it too. So read from it and see if all is ok. – greenapps Jul 13 '15 at 07:57
  • Does this answer your question? [Debugging sqlite database on the device](https://stackoverflow.com/questions/6928849/debugging-sqlite-database-on-the-device) – Ryan M Aug 07 '20 at 18:17

2 Answers2

5

This is the Best Lib I Found to debug your database

https://github.com/amitshekhariitbhu/Android-Debug-Database

No Need to download any file. Simple Intigration. Simple Browser View.

What can Android Debug Database do?

  • See all the databases.
  • See all the data in the shared preferences used in your application.
  • Run any sql query on the given database to update and delete your data.
  • Directly edit the database values.
  • Directly edit the shared preferences.
  • Directly add a row in the database.
  • Directly add a key-value in the shared preferences.
  • Delete rows and shared preferences.
  • Search in your data. Sort data.
  • Download database.

Using Android Debug Database Library in your application

Add this to your app's build.gradle

debugCompile 'com.amitshekhar.android:debug-db:1.0.1'

ScreenShot

Hope This would help.

4

There is an command-line version of sqlite3 available that allows you to directly access/view/modify an SQLite database in the adb (root) shell on the Android device without having to copy the database to your computer.

Of course you need root on the device, otherwise you can not access the app private directory with the database inside.

Edit: Some Android SQLite tools seem to implement something like an remote interface or a GUI for the command-line sqlite3 tool as described above. I have not tested it but SQLiteStudio in combination with it's DBAndroid plugin seem to provide GUI access from the PC to a database on the Android phone (without copying the database). Unfortunately the plugin is not free (commercial)

Robert
  • 39,162
  • 17
  • 99
  • 152
  • Thank You! Sounds like a good solution, i will check this out. – Michael B Jul 13 '15 at 08:29
  • 1
    I comment today because i actively use this tool (SQLiteStudio + DBAndroid) and it's now free and GPL but you can donate to the author. He's very reactive !!! – coutier eric May 06 '16 at 21:25