Using the android debug database library

In this article, I am going to quickly introduce you to an android library that I find useful a lot. Android Debug Database is a powerful library developed by Mindorks for debugging databases and shared preferences in Android applications. Meaning it gives you the ability to visualize your local database and shared preferences and even edit or delete them.

Although Google, as at this day, has released an android studio feature called Database Inspector in the latest version of Android Studio 4.1 that would allow you to do this, I still have to release this, cause well, I’ve had this for a while in my draft 😄. Also, this gives you added advantage of accessing your SharedPreferences.

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 database rows and shared preferences.
  • Search in your data.
  • Sort data.
  • Download database.

I’m just going to do a quick intro into it and let you dig in further if you need to.

Installation

1. Add this to your app’s build.gradle

debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

2.

Connect your Android phone and laptop to the same Network (Wifi or LAN)

OR

If you are using it over USB, run adb forward tcp:8080 tcp:8080 in your terminal.

3. Run the application, you will see in the logcat an entry like follows:

D/DebugDB: Open http://XXX.XXX.X.XXX:8080 in your browser

Open the provided link in your browser. And that’s it!

User Interface

If everything is all good, you should see something like this in your browser.

Android Debug Database View

Here, I have decided to test this out using an old project of mine, Github Stalker, where I made use of Room database, displaying a list of top android repos.

You can easily view, edit or delete entries in your database, as shown below:

Android Debug Database Edit

Also, same way as the database, you can view your SharedPreferences, as shown below:

Android Debug Database SharedPreferences

Likewise, you can edit or delete from your SharedPreferences as shown below:

Android Debug Database SharedPreferences Edit

So, that’s it! Easy right?


To make use of extra features such as making use of DB password, using a different port other than 8080, working with emulator, getting address in code, etc., check out the library here. Other alternatives to this library are Stetho by Facebook and of course, the Android Studio Database Inspector.

So, that’s all for this article. Till next time, I say #StayHomeStaySafe. ✌🏽