Android library for viewing, editing 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.3.0"
releaseImplementation "com.infinum.dbinspector:dbinspector-no-op:5.3.0"

KotlinDSL

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

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
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app

DroidMVP About DroidMVP is a small Android library to help you incorporate the MVP pattern along with Passive View and Presentation Model (yes, those

Andrzej Chmielewski 225 Nov 29, 2022
A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

Yashovardhan Dhanania 35 Dec 10, 2022
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

Mauricio Togneri 13 Aug 29, 2022
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Rohit Surwase 19 Nov 9, 2021
Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Shahid Iqbal 4 Nov 29, 2022
A library for fast and safe delivery of parameters for Activities and Fragments.

MorbidMask - 吸血面具 Read this in other languages: 中文, English, Change Log A library for fast and safe delivery of parameters for Activities and Fragment

Season 67 Mar 29, 2022
Android Market In-app Billing Library

Update In-app Billing v2 API is deprecated and will be shut down in January 2015. This library was developed for v2 a long time ago. If your app is st

Robot Media 533 Nov 25, 2022
UPnP/DLNA library for Java and Android

Cling EOL: This project is no longer actively maintained, code may be outdated. If you are interested in maintaining and developing this project, comm

4th Line 1.6k Jan 4, 2023
Android library to easily serialize and cache your objects to disk using key/value pairs.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Anup Cowkur 667 Dec 22, 2022
Error handling library for Android and Java

ErrorHandler Error handling library for Android and Java Encapsulate error handling logic into objects that adhere to configurable defaults. Then pass

null 237 Dec 29, 2022
A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Wesley Lin 134 Nov 25, 2022
POC Simulate Backend Biometric Authentication with AIDL (client app/server app)

poc-simulate-bio-auth-aidl POC Simulate Backend Biometric Authentication with AIDL (client app/server app) #How to use Install server app and run Inst

gundamD 0 Dec 30, 2021
A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop

vector-compat A support library for VectorDrawable and AnimatedVectorDrawable introduced in Lollipop with fully backwards compatible tint support (api

Wael N 1.2k Nov 29, 2022
A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

MarvinLabs 420 Nov 20, 2022
A library to quickly and easily enable multiple monitoring & support platforms for your mobile apps

You have a small team. Setting up crash reporting tools, event tracking tools, and log management services is not what you want to spend your hours do

Percolate 65 Aug 8, 2022
A lightweight library for config and using SharedPreferences

preferences-helper SharePreferences is very popular with any project and all most all project has SharePreferences for saving data. This library will

Khang Tran 23 May 8, 2021
SharedPreference Library to save all types including your custom types and observe them if need be.

A SharedPreference Library that can be used to store all types including your custom classes and observe them too if needed.

Ehma Ugbogo 18 Nov 10, 2021
🐫🐍🍢🅿 Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case

KaseChange Multiplatform Kotlin library to convert strings between various case formats Supported Case Formats SCREAMING_SNAKE_CASE snake_case PascalC

PearX Team 67 Dec 30, 2022
Multiplaform kotlin library for calculating text differences. Based on java-diff-utils, supports JVM, JS and native targets.

kotlin-multiplatform-diff This is a port of java-diff-utils to kotlin with multiplatform support. All credit for the implementation goes to original a

Peter Trifanov 51 Jan 3, 2023