A library for debugging android databases and shared preferences - Make Debugging Great Again

Overview

Android Debug Database

Mindorks Mindorks Community Mindorks Android Store API Download Open Source Love License

Android Debug Database is a powerful library for debugging databases and shared preferences in Android applications

Android Debug Database allows you to view databases and shared preferences directly in your browser in a very simple way

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.
  • Debug Room inMemory database.

All these features work without rooting your device -> No need of rooted device

Check out our other Open Source Projects

Using Android Debug Database Library in your application

Add this to your app's build.gradle

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

Using the Android Debug Database with encrypted database

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

And to provide the password for the DB, you should add this in the Gradle: DB_PASSWORD_{VARIABLE}, if for example, PERSON is the database name: DB_PASSWORD_PERSON

debug {
    resValue("string", "DB_PASSWORD_PERSON", "password")
}

Use debugImplementation so that it will only compile in your debug build and not in your release build.

That’s all, just start the application, you will see in the logcat an entry like follows :

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

  • You can also always get the debug address url from your code by calling the method DebugDB.getAddressLog();

Now open the provided link in your browser.

Important:

  • Your Android phone and laptop should be connected to the same Network (Wifi or LAN).
  • If you are using it over usb, run adb forward tcp:8080 tcp:8080

Note : If you want use different port other than 8080. In the app build.gradle file under buildTypes do the following change

debug {
    resValue("string", "PORT_NUMBER", "8081")
}

You will see something like this :

Seeing values

Editing values

Working with emulator

  • Android Default Emulator: Run the command in the terminal - adb forward tcp:8080 tcp:8080 and open http://localhost:8080
  • Genymotion Emulator: Enable bridge from configure virtual device (option available in genymotion)

Getting address with toast, in case you missed the address log in logcat

As this library is auto-initialize, if you want to get the address log, add the following method and call (we have to do like this to avoid build error in release build as this library will not be included in the release build) using reflection.

public static void showDebugDBAddressLogToast(Context context) {
    if (BuildConfig.DEBUG) {
       try {
            Class<?> debugDB = Class.forName("com.amitshekhar.DebugDB");
            Method getAddressLog = debugDB.getMethod("getAddressLog");
            Object value = getAddressLog.invoke(null);
            Toast.makeText(context, (String) value, Toast.LENGTH_LONG).show();
       } catch (Exception ignore) {

       }
    }
}

Adding custom database files

As this library is auto-initialize, if you want to debug custom database files, add the following method and call

public static void setCustomDatabaseFiles(Context context) {
    if (BuildConfig.DEBUG) {
        try {
            Class<?> debugDB = Class.forName("com.amitshekhar.DebugDB");
            Class[] argTypes = new Class[]{HashMap.class};
            Method setCustomDatabaseFiles = debugDB.getMethod("setCustomDatabaseFiles", argTypes);
            HashMap<String, Pair<File, String>> customDatabaseFiles = new HashMap<>();
            // set your custom database files
            customDatabaseFiles.put(ExtTestDBHelper.DATABASE_NAME,
                    new Pair<>(new File(context.getFilesDir() + "/" + ExtTestDBHelper.DIR_NAME +
                                                    "/" + ExtTestDBHelper.DATABASE_NAME), ""));
            setCustomDatabaseFiles.invoke(null, customDatabaseFiles);
        } catch (Exception ignore) {

        }
    }
}

Adding InMemory Room databases

As this library is auto-initialize, if you want to debug inMemory Room databases, add the following method and call

public static void setInMemoryRoomDatabases(SupportSQLiteDatabase... database) {
    if (BuildConfig.DEBUG) {
        try {
            Class<?> debugDB = Class.forName("com.amitshekhar.DebugDB");
            Class[] argTypes = new Class[]{HashMap.class};
            HashMap<String, SupportSQLiteDatabase> inMemoryDatabases = new HashMap<>();
            // set your inMemory databases
            inMemoryDatabases.put("InMemoryOne.db", database[0]);
            Method setRoomInMemoryDatabase = debugDB.getMethod("setInMemoryRoomDatabases", argTypes);
            setRoomInMemoryDatabase.invoke(null, inMemoryDatabases);
        } catch (Exception ignore) {

        }
    }
}

Find this project useful ? ❤️

  • Support it by clicking the button on the upper right of this page. ✌️

TODO

  • Simplify emulator issue Issue Link
  • And of course many more features and bug fixes.

Check out Mindorks awesome open source projects here

Contact - Let's become friends

License

   Copyright (C) 2019 Amit Shekhar
   Copyright (C) 2011 Android Open Source Project

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Contributing to Android Debug Database

All pull requests are welcome, make sure to follow the contribution guidelines when you submit pull request.

Comments
  • It said

    It said "Open http://0.0.0.0.8080/ in your browser"

    I could install the apk in my device successfully, but it said "Open http://0.0.0.0.8080/ in your browser". There is indeed domain name resolution error. I don't know how to resolve this issue now. It both happens on emulator and real device..

    opened by mmavis 8
  • Apk size huge increase after adding SqlCipher support (v1.0.2+)

    Apk size huge increase after adding SqlCipher support (v1.0.2+)

    After upgrading to latest version, apk size is increased by 13MB .so files, that ,as I guess, are used to support SqlCipher. Is there a way to exclude it?

    enhancement 
    opened by androideveloper 7
  • Help to fix Issue #50 - Reduce horizontal scrolling on web page, and show more content

    Help to fix Issue #50 - Reduce horizontal scrolling on web page, and show more content

    1. Clarify button text to download database file. Change text: "Export Selected Database : " to "Click here to Download Database : "

    2. Use horizontal space better on bootstrap.min.css

    • For main page body, reduce large margins on left and right. Modify ".container" CSS style.
    • For the 3 table columns: "Databases", "Tables", "Data", reduce gap in between these columns. Modify ".col-lg-1, ..." CSS style
    • For first 2 columns in table: "Databases" and "Tables", expand the width. Modify ".col-sm-2" CSS style
    • For 3rd table column "data", make the column take the full width of page, below the first 2 columns. Modify ".col-sm-8" CSS style

    Before screenshot of web page:

    1 before android_debug_database_-_2017-09-04_12 47

    After screenshot of web page:

    2 after android_debug_database_-_2017-09-04_13 13

    opened by ozmium 7
  • After updating to 1.0.5 type `com.amitshekhar.DebugDB` not available

    After updating to 1.0.5 type `com.amitshekhar.DebugDB` not available

    As implied in the title, after updating to the latest version I can't use com.amitshekhar.DebugDB to access DebugDB.getAddressLog()

    I am importing as follows: debugImplementation 'com.amitshekhar.android:debug-db:1.0.5'

    opened by sum-elier 6
  • NullPointerException

    NullPointerException

    When starting my Application a huge error log is written: Pastebin

    After that my Application is crashing with a NullPointerException

    E/ClientServer: Exception. java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.HashMap.get(java.lang.Object)' on a null object reference at com.amitshekhar.server.RequestHandler.openDatabase(RequestHandler.java:182) at com.amitshekhar.server.RequestHandler.getTableListResponse(RequestHandler.java:304) at com.amitshekhar.server.RequestHandler.handle(RequestHandler.java:113) at com.amitshekhar.server.ClientServer.run(ClientServer.java:76) at java.lang.Thread.run(Thread.java:762)

    opened by Kandr0s 6
  • Not Working on Genymotion

    Not Working on Genymotion

    Hi, it is not working on my end. It keeps loading the web page. It is said in the log:

    D/DebugDB: Open http://10.0.3.15:8081 in your browser
    

    But it was loading then said that the site can't be reached. Is there anything wrong? FYI, i use kotlin and there is no java folder inside src. Another info:

    • Min sdk is 15
    • Compile sdk is 25
    • build tools version 25.0.0
    • target sdk 25
    • tested on Genymotion 4.1.1

    Please help, thanks!

    question 
    opened by elsennov 6
  • It seems can not load any data?

    It seems can not load any data?

    I think this project is great, so I write a test app to see it's feature. I'm sure my phone and my computer are in the same WIFI. When open the browser, just like this, it has a welcome button, can't see my DB, what's wrong? image

    opened by DearZack 5
  • Added SqlCipher support

    Added SqlCipher support

    Very quick integration with Sqlcipher. Basically I've changed the map of Database file list from Map<String, File> to Map<String, Pair<File, String>> where the last string is the database password.

    This is my little contribution to this useful project ;)

    Marco

    opened by mstarita 4
  • Pragma doesn't work

    Pragma doesn't work

    Hi,

    If I try to execute query like PRAGMA table_info(myTable); I'll get error. Root cause is in DatabaseHelper class in method executeQueryAndGetResponse. It checks if first word in query is "select" and does query otherwise does execSql which doesn't support results.

    I think this could be solved by checking for "pragma" as well and in that case executing "getTableInfo" method.

    enhancement 
    opened by Boza-s6 4
  • Can't see custom database location?

    Can't see custom database location?

    It seems you take DBs from com.package.packagename/databases/ My DB location is in com.package.packagename/files/myfolder/mydatabase.db . So, How can I see for custom database. Thanks

    opened by htooaunghlaing 4
  • Update dependencies and minor project cleanups

    Update dependencies and minor project cleanups

    This PR contains several project cleanups and updates all dependencies to the latest versions.

    Gradle wrapper scripts automatically updated by the wrapper task (files not manually modified!).

    Please see individual commits for details.

    Closes #134 Includes and closes #111

    Once approved, please use a normal GitHub merge (i.e. NO rebase/squash merge) to integrate the commit(s) from the branch of this pull request. The changes are broken up into meaningful, atomic commits, and my branch should already be up-to-date with the latest target branch. If it isn't, or if you'd like me to combine something, please let me know, and I will make the necessary updates as soon as possible. Thank you!

    opened by friederbluemle 3
  • NetworkUtils.java line 38

    NetworkUtils.java line 38

    Fatal Exception: java.lang.RuntimeException: Unable to get provider com.amitshekhar.debug.DebugDBInitProvider: java.lang.SecurityException: WifiService: Neither user 12175 nor current process has android.permission.ACCESS_WIFI_STATE.
           at android.app.ActivityThread.installProvider(ActivityThread.java:6770)
           at android.app.ActivityThread.installContentProviders(ActivityThread.java:6312)
           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6227)
           at android.app.ActivityThread.access$1200(ActivityThread.java:238)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1787)
           at android.os.Handler.dispatchMessage(Handler.java:106)
           at android.os.Looper.loop(Looper.java:214)
           at android.app.ActivityThread.main(ActivityThread.java:7073)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
    
    Caused by java.lang.SecurityException: WifiService: Neither user 12175 nor current process has android.permission.ACCESS_WIFI_STATE.
           at android.os.Parcel.createException(Parcel.java:1966)
           at android.os.Parcel.readException(Parcel.java:1934)
           at android.os.Parcel.readException(Parcel.java:1884)
           at android.net.wifi.IWifiManager$Stub$Proxy.getConnectionInfo(IWifiManager.java:1786)
           at android.net.wifi.WifiManager.getConnectionInfo(WifiManager.java:2057)
           at com.amitshekhar.utils.NetworkUtils.getAddressLog(NetworkUtils.java:38)
           at com.amitshekhar.DebugDB.initialize(DebugDB.java:62)
           at com.amitshekhar.debug.DebugDBInitProvider.onCreate(DebugDBInitProvider.java:44)
           at android.content.ContentProvider.attachInfo(ContentProvider.java:1940)
           at android.content.ContentProvider.attachInfo(ContentProvider.java:1915)
           at com.amitshekhar.debug.DebugDBInitProvider.attachInfo(DebugDBInitProvider.java:83)
           at android.app.ActivityThread.installProvider(ActivityThread.java:6765)
           at android.app.ActivityThread.installContentProviders(ActivityThread.java:6312)
           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6227)
           at android.app.ActivityThread.access$1200(ActivityThread.java:238)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1787)
           at android.os.Handler.dispatchMessage(Handler.java:106)
           at android.os.Looper.loop(Looper.java:214)
           at android.app.ActivityThread.main(ActivityThread.java:7073)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
    
    Caused by android.os.RemoteException: Remote stack trace:
            at android.app.ContextImpl.enforce(ContextImpl.java:1924)
            at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1952)
            at com.android.server.wifi.WifiServiceImpl.enforceAccessPermission(WifiServiceImpl.java:1580)
            at com.android.server.wifi.WifiServiceImpl.getConnectionInfo(WifiServiceImpl.java:3646)
            at android.net.wifi.IWifiManager$Stub.onTransact(IWifiManager.java:341)
    

    Device Brand:samsung Model:Galaxy S8 Version: Android 9

    opened by Drjacky 1
  • Password field in browser to prevent unauthorized access

    Password field in browser to prevent unauthorized access

    We want to keep the library installed for our internal application in production for research reasons. Is there a way to protect the web frontend from unauthorized access?

    For example by setting a password that has to be entered when accessing the web ui.

    opened by MaaxGr 0
Releases(v1.0.6)
Owner
AMIT SHEKHAR
Always Learning and Sharing | Co-Founder @ MindOrks, AfterAcademy, CuriousJr
AMIT SHEKHAR
Pluto: An on-device debugging framework for Android applications

Pluto is an on-device debugging framework for Android applications, which helps in the inspection of HTTP requests/responses, captures Crashes, and ANRs, and manipulates application data on the go.

Pluto 550 Dec 27, 2022
A surgical debugging tool to uncover the layers under your app.

Scalpel DEPRECATED! Android Studio 4.0's layout inspector now includes a live-updating 3D view. Use it! A surgical debugging tool to uncover the layer

Jake Wharton 2.8k Jan 9, 2023
Easier RxJava2 debugging with better stacktraces

Traceur Traceur enables easier debugging of RxJava2 exceptions, by appending the source of any asynchronous calls to the original exception. An exampl

Oisin O'Neill 493 Dec 18, 2022
A model-agnostic visual debugging tool for machine learning

Manifold This project is stable and being incubated for long-term support. Manifold is a model-agnostic visual debugging tool for machine learning. Un

Uber Open Source 1.6k Dec 25, 2022
Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.

Under the Hood - Android App Debug View Library Under the Hood is a flexible and powerful Android debug view library. It uses a modular template syste

Patrick Favre-Bulle 217 Nov 25, 2022
Android library to record the network calls through the interceptor mechanism of the http clients.

Android Snooper Introduction Android Snooper is a library which helps in debugging issues while running the applications on android devices. One of th

Prateek 151 Nov 25, 2022
Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.

Stetho Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature nat

Facebook 12.6k Jan 7, 2023
🔪Swiss-army knife for Android testing and development 🔪 ⛺

ADB Enhanced ADB-Enhanced is a Swiss-army knife for Android testing and development. A command-line interface to trigger various scenarios like screen

Ashish Bhatia 938 Dec 20, 2022
A Read-Eval-Print-Loop server for Android and SQLite

Android DebugPort Android DebugPort is a drop-in utility which allows you to write and execute code within your app's context, at runtime, and from th

Jason Feinstein 148 Nov 14, 2022
Easy android exception tracer and handler.

Introduction Lup is a small android library that can help you to tracking bug that causes application stopped working (force close). Whiting this libr

icodeu 4 Sep 29, 2022
Android QA/Debug tools to speed up and streamline the development progress.

Android Dev Tools is a library that contains various QA/Debug tools to speed up and streamline the development progress.

Trendyol Open Source 105 Dec 5, 2022
Cordova plugin for Android Serial USB communication (easily connect an Arduino board to an Android device).

PR-DC cordova-plugin-serialusb Cordova plugin for Android Serial USB communication. This plugin makes a connection to the external board trivial, for

PR-DC 3 May 8, 2022
Sources for the LiveBoot app for rooted Android devices

This is the sauce for the LiveBoot app. License Copyright © 2011-2020 Jorrit Chainfire Jongma This code is released under the GPLv3. LICENSE, COPYING.

Chainfire 131 Jan 9, 2023
android logcat

android logcat

Ji Sungbin 3 Dec 2, 2022
A local ADB shell for Android!

LADB A local ADB shell for Android! How does it work? LADB bundles an ADB server within the app libraries. Normally, this server cannot connect to the

Tyler 1.1k Jan 2, 2023
btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Systrace

btrace README 中文版 btrace(AKA RheaTrace) is a high performance Android trace tool

Bytedance Inc. 1.2k Jan 4, 2023
Plugin-shared-preferences - Pluto plugin to manage your Shared Preferences

Pluto Shared Preferences Plugin Pluto Shared Preferences is a Pluto plugin to in

Pluto 1 Feb 14, 2022
Reactor is key value database and is a great alternative to Shared Preferences.

Reactor Reactor is a fast and secure key-value library for Android, and has an embedded database based on the JSON structure and is a great alternativ

mr amir abbas 37 Oct 30, 2022