Android library for viewing and sharing in app databases.

Overview

Download Validate Gradle Wrapper Code analysis CodeFactor codecov

DbInspector

UI

DbInspector provides a simple way to view the contents of the in-app database for debugging purposes. There is no need to pull the database from a connected device. This library supports inspecting of the SQLite databases created by CouchBase Lite out of the box. With this library you can:

  • preview all application sandbox databases
  • import single or multiple databases at once
  • search, delete, rename, copy, share a database
  • preview tables, views and triggers
  • preview table or view pragma
  • delete table contents
  • drop view or trigger
  • search table, view or trigger
  • sort table, view or trigger per column

Getting started

To include DbInspector in your project, you have to add buildscript dependencies in your project level build.gradle or build.gradle.kts:

Groovy

buildscript {
    repositories {
        mavenCentral()
    }
}

KotlinDSL

buildscript {
    repositories {
        mavenCentral()
    }
}

Then add the following dependencies in your app build.gradle or build.gradle.kts :

Groovy

debugImplementation "com.infinum.dbinspector:dbinspector:5.2.8"
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.2.8"

KotlinDSL

debugImplementation("com.infinum.dbinspector:dbinspector:5.2.8")
releaseImplementation("com.infinum.dbinspector:dbinspector-no-op:5.2.8")

Usage

DbInspector can be invoked explicitly or implicitly.

  • explicitly - call DbInspector.show() anywhere and anytime that you see fit, like onClick methods, lambdas or similar.
  • implicitly - when you add the dbinspector package an Activity alias is automatically merged into your application manifest that in return creates a launcher icon for DbInspector, but when you add the dbinspector-no-op the same Activity alias node is automatically removed from your application manifest. Implicit way can be tweaked to achieve desired behaviour as demonstrated in an example below.

Explicit

DbInspector.show()

Implicit If you use dbinspector package but do not want an additional automatic launcher icon merged in and generated.

<!--suppress AndroidDomInspection -->
<activity-alias
    android:name="com.infinum.dbinspector.DbInspectorActivity"
    tools:node="remove" />

If you use DbInspector for a specific flavor and need to override merged in launcher label, you can provide a String resource in your project exactly like this:

<string name="dbinspector_launcher_name">Sample Debug</string>

Please do mind and copy over the suppression comment line too, if you need it. Further modification can be done according to rules of manifest merging and attributes of activity-alias XML node.

Requirements

Minimum required API level to use DbInspector is 21 known as Android 5.0, Lollipop. As of 4.0.0 version, AndroidX is required. If you cannot unfortunately migrate your project, keep the previous version until you get the opportunity to migrate to AndroidX. DbInspector is written entirely in Kotlin, but also works with Java only projects and all combinations of both.

Contributing

Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same license. For easier developing a sample application with proper implementations is provided. It is also recommended to change build.debug property in build.properties to toggle dependency substitution in project level build.gradle. Then create a pull request.

License

Copyright 2020 Infinum

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.

Credits

Maintained and sponsored by Infinum.

Comments
  • Unnecessary Timber plant

    Unnecessary Timber plant

    :writing_hand: Describe the bug

    Here: https://github.com/infinum/android_dbinspector/blob/master/dbinspector/src/main/kotlin/com/infinum/dbinspector/DbInspector.kt#L15-L18 you are using Stump tree on release builds. Is that really necessary? Every time i open DbInspector my logging tree gets bigger with useless tree. Why not just plant debug tree on debug build and else do nothing?

    Also - i think you should use some static flag to mark that tree was already planted and not do that again on every inspector open.

    And while we're at that - could you make logging optional? I could even do that with simple PR. The reason is quite weird - i have to store logs in local db. I'm using Timber.Tree to do that. And now every time i go in DbInspector i have logs spam about the connection i just made to look at logs table. I would love to just turn that off (or maybe use some TAG for DbInspector, then i could just filter those out

    enhancement 
    opened by jakoss 11
  • Using unstable dependencies by library

    Using unstable dependencies by library

    :writing_hand: Describe the bug

    For now - version 5.0.0 seems great, but it's based on fragmentx 1.3.0.beta, which is unstable. After upgrading your library to newest version i got a handful of deprecation notices. I'm not really fond of using unstable libraries from google at production applications, so this is a killer problem for me here. Could you consider sticking with stable libraries for stable library releases? A lot of libraries are doing unstable releases and in those releases they can use unstable dependencies too (FlowBinding for example)

    enhancement question ongoing 
    opened by jakoss 11
  • Build error after updating Android support libs to v23.2

    Build error after updating Android support libs to v23.2

    Using

    compile 'com.android.support:support-v4:23.2.0'
    compile 'com.android.support:appcompat-v7:23.2.0'
    

    along with debugCompile 'im.dino:dbinspector:3.2.2@aar'

    results in the build error:

    :app:processDebugResources
    /Users/dino/android/dbinspector/dbinspector/src/main/res/menu/dbinspector_fragment_table_list.xml:13: AAPT: No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_menu_copy_mtrl_am_alpha').
    /Users/dino/android/dbinspector/dbinspector/src/main/res/menu/dbinspector_fragment_table_list.xml:21: AAPT: No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_menu_share_mtrl_alpha').
    
     FAILED
    

    If I revert back to 23.1.1 for the support libs, the issue goes away.

    opened by MarcBernstein 7
  • Not showing databases in sdcard

    Not showing databases in sdcard

    My app makes database in Phone Storage and SD card. It is Showing data of Phone Storage but not of sdcard. Location of my db id sdcard/android/data/<myapp_package_name>/files/<database.db>. Is it not supported or just an issue??

    opened by Aexyn 6
  • App crashes when trying to open a Couchbase DB (version 1.2.1)

    App crashes when trying to open a Couchbase DB (version 1.2.1)

    I tried to use this library to see the content of a Couchbase db.

    Whenever I try to open the .cblite2 DB the app crashes with the following exception:

    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:318) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:228) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:512) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:908) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:878) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:699) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:714) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:707) at im.dino.dbinspector.helpers.CursorOperation.execute(CursorOperation.java:20) at im.dino.dbinspector.helpers.DatabaseHelper.getAllTables(DatabaseHelper.java:164) at im.dino.dbinspector.fragments.TableListFragment.onActivityCreated(TableListFragment.java:133) at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1983) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570) at im.dino.dbinspector.fragments.DatabaseListFragment.onItemClick(DatabaseListFragment.java:45) at android.widget.AdapterView.performItemClick(AdapterView.java:334) at android.widget.AbsListView.performItemClick(AbsListView.java:1536) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3683) at android.widget.AbsListView$3.run(AbsListView.java:5604) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6134) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

    Any idea of how to solve it ?

    opened by gmbett 5
  • Can you remove intent-filter please?

    Can you remove intent-filter please?

    Thanks for your great library.

    I'd suggest remove intent-filter for the main activity, because I don't wanna my apps create another icon on my launcher even it just apply to the debug release. Especially when you consider there would have many apps using this library. And because this is a library for developers, it would be easy for them to add those XML if they really need this.

    And for developers who want this happen, one quick solution is put following statement in your manifest.xml

            <activity
                android:name="im.dino.dbinspector.activities.DbInspectorActivity">
                <intent-filter tools:node="removeAll">
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
    opened by soarcn 5
  • Cannot use 5.4.0

    Cannot use 5.4.0

    :writing_hand: Describe the bug

    Trying to use 5.4.0 ends up with:

    Execution failed for task ':app:processDebuggableDevDebugResources'.
    > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
       > Android resource linking failed
         ERROR:C:\Users\Jakub\.gradle\caches\transforms-3\35bca2fadd1db3e7a978d8a5f1446405\transformed\dbinspector-5.4.0\res\values\values.xml:346:5-351:13: AAPT: error: style attribute 'android:attr/windowBlurBehindEnabled' not found.
             
         ERROR:C:\Users\Jakub\.gradle\caches\transforms-3\35bca2fadd1db3e7a978d8a5f1446405\transformed\dbinspector-5.4.0\res\values\values.xml:346:5-351:13: AAPT: error: style attribute 'android:attr/windowBlurBehindRadius' not found.
    
    bug 
    opened by jakoss 4
  • Improve BLOB representation

    Improve BLOB representation

    :warning: Please describe your feature request

    Currently, all BLOBs are displayed as (data). This is not a very descriptive representation of the stored data.

    :bulb: Describe the solution you'd like

    A simple improvement would be to show all BLOBs as a hex string. This would help with data types such as byte arrays. An advanced improvement would be showing different representation based on the BLOB type. For example, images could be rendered within the cell - possibly initially as a thumbnail with an option to expand.

    :raising_hand: Do you want to develop this feature yourself?

    • [ ] Yes
    • [x] No
    enhancement feature 
    opened by JonatanPlesko 4
  • Added New features and support for older versions

    Added New features and support for older versions

    Added three new features.

    1. Database version (can be shown in subtitle
    2. Menu for search tables
    3. Menu for copy database in memory card for further testing. (Can be used with ADB pull to copy it in PC and run it in Sqlite editor)

    Added Support for older versions using support fragments and support fragment manager. For Preference Fragment I have used code from here

    opened by PrashamTrivedi 4
  • Feature: custom table format (long text, timestamp, etc.)

    Feature: custom table format (long text, timestamp, etc.)

    Allows developers to specify custom formatting on per table/column level, which can be used support:

    • display of long text (limit max-width of the column and truncate the text), one way for #31
    • display timestamp (unix epoch in long) in human-readable format
    • human-friendly display of floating point numbers, e.g., limit to 2 decimal places.

    See the changes in ExampleApp.java for usage.

    opened by orionlee 3
  • kv_default does not show meaningful data

    kv_default does not show meaningful data

    Hi I've been recently evaluating Couchbase Lite for my company's apps, and I think the android db inspector is a pretty cool concept to inspect the contents of our apps's dbs when debugging. But I can't seem to view any meaningful data about my database. In the version and body columns all it shows me is the word (data), like so:

    couchbase

    I guess I expected it to show me the key/value pairs for each document within the db. Am I missing something?

    opened by andredoubleu 3
Releases(v5.4.9)
Owner
Infinum
We're an independent design & development agency of 230 people, creating beautiful software for 14 years.
Infinum
an android library for debugging what we care about directly in app.

EN | 中文 Pandora is a tool box that allows you to inspect and modify what includes networks, databases, UIs, etc. directly in your application. It is s

linjiang 1.5k Dec 30, 2022
A library for reading Shared Preferences and Database values within the application.

AppDataReader A library for reading and writing Shared Preferences and Database values of the application within the device. Advantages of using this

Anshul Jain 124 Nov 25, 2022
A small library to help with Realm.IO integration in Android apps

Android Realm Asset Helper A small library of methods to help with Realm.IO integration in Android apps Copies a realm database from a the assets fold

Quality Mobile Puzzle Apps 29 Dec 28, 2021
Pref-DB - Android SharedPreferences alternative library

Pref-DB Android SharedPreferences alternative library.

M.Fakhri 5 Sep 14, 2022
A helper library to help using Room with existing pre-populated database [].

Room now supports using a pre-packaged database out of the box, since version 2.2.0 https://developer.android.com/jetpack/androidx/releases/room#2.2.0

Ibrahim Eid 136 Nov 29, 2022
An Android helper class to manage database creation and version management using an application's raw asset files

THIS PROJECT IS NO LONGER MAINTAINED Android SQLiteAssetHelper An Android helper class to manage database creation and version management using an app

Jeff Gilfelt 2.2k Jan 7, 2023
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
Kodein-DB is a Kotlin/Multiplatform embedded NoSQL database that works on JVM, Android, Kotlin/Native and iOS.

Kodein-DB is a Kotlin/Multiplatform embedded NoSQL database that works on JVM, Android, Kotlin/Native and iOS. It is suited for client or mobile applications.

null 277 Dec 3, 2022
A wrapper around Android's SQLiteDatabase with restoring capability

Restorable SQLiteDatabase RestorableSQLiteDatabase is a wrapper to replicate android's SQLiteDatabase class with restoring capability. This wrapper ma

Navid 21 Oct 21, 2022
A key-value database for Android

SnappyDB SnappyDB is a key-value database for Android it's an alternative for SQLite if you want to use a NoSQL approach. It allows you to store and g

Nabil Hachicha 1.8k Dec 28, 2022
Insanely easy way to work with Android Database.

Sugar ORM Insanely easy way to work with Android databases. Official documentation can be found here - Check some examples below. The example applicat

null 2.6k Dec 16, 2022
Android Database Performance Benchmarks

ℹ Check out our new performance test app that includes ObjectBox. Android Database Performance Benchmark This project evaluates Android databases and

Markus Junginger 80 Nov 25, 2022
Core Data for Android

NexusData Core Data for Android NexusData is an object graph and persistence framework for Android. It allows for organizing and managing relational d

Dia Kharrat 71 Nov 11, 2022
🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

?? Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.

Jaewoong Eum 276 Jan 5, 2023
Test any type of cloud database on Android apps. No need of a dedicated backend.

Test any type of cloud database on Android apps. No need of a dedicated backend.

Arjun 9 May 9, 2022
Android with Real-time Database

Android with Real-time Database It was too much effort to build my own real-time database, but the result really satisfying, so it was worth it. Note

null 4 Jun 14, 2022
Android library for viewing, editing and sharing in app databases.

DbInspector DbInspector provides a simple way to view the contents of the in-app database for debugging purposes. There is no need to pull the databas

Infinum 924 Jan 4, 2023
Ride-Sharing Uber Lyft Android App - Learn to build a ride-sharing Android Taxi Clone App like Uber, Lyft - Open-Source Project By MindOrks

Ride-Sharing Uber Lyft Android App - Learn to build a ride-sharing Android Taxi Clone App like Uber, Lyft - Open-Source Project By MindOrks

MindOrks 1.2k Dec 29, 2022
Meme-Sharing-App - Meme Sharing App Built With Kotlin

'Meme Share' is an android application by virtue of which the user can view and

Utkarsh Panwar 0 Jan 30, 2022
App for viewing passwords for the Nextcloud Passwords app.

Nextcloud Passwords WARNING: This app is still in progress, and thus some features like password editing or creation are not done yet. This app connec

Hèctor Godoy 6 Dec 2, 2022