当前位置: 首页 > 软件库 > 手机/移动开发 > >

Android-Debug-Database

授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 曾阳飙
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Android Debug Database

Open Source Love

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 guidelineswhen you submit pull request.

  • 1.GitHub地址 Android-Debug-Database 2.添加依赖项 在app的build.gradle添加 dependencies { debugCompile 'com.amitshekhar.android:debug-db:1.0.4' } 复制代码 3.真机访问(手机和电脑必须在同一个局域网上) 点击那个地址就可以直接访问了,也能在浏览器中手动输入。默认地

  • 项目地址: https://github.com/amitshekhariitbhu/Android-Debug-Database    具体作用: 查看所有的databases 查看应用程序中所使用的shared preferences所有数据 在给定数据库中运行SQL语句进行增删改查的操作 直接编辑数据库的值 直接编辑shared preferences的值 直接在数据库中添加一行数据 在sh

  • 使用参考:http://www.jianshu.com/p/89ccae3e590b 源码地址:https://github.com/amitshekhariitbhu/Android-Debug-Database 特色: 可以查看你的应用中所有的数据库。 可以查看你的应用中所有的shared preferences。 对你指定的数据库执行SQL语句。 对你指定的数据库中的数据进行可视化的编辑。

  • LitePal项目地址:LitePal github项目地址 Android-Debug-Database项目地址:项目地址

 相关资料
  • adb 是一个独立第三方开发的 Android Debug Bridge( ADB ) 工具。 adb 是 Android SDK 中的一个工具, 使用 ADB 的时候需先将 Android SDK 安装到目录路径中。使用 ADB 可以直接操作管理 Android 模拟器或者真实的 Andriod 设备。 ADB 主要功能有: 可在 Android 设备上运行 Shell 命令行 管理模拟器或设备

  • Attribute Name Type Required Default Description output string No html output type, html or javascript 属性 类型 是否必须 缺省值 描述 output string No html 输出类型,html或javascript {debug} dumps the debug console to t

  • The debug component enables component-to-DOM serialization. Example < a-scene debug> </ a-scene> Com

  • 在本章中,我们将研究Joomla中的Debug 。 通过启用调试模式,它有助于解决Joomla的各种问题。 它显示了Joomla如何呈现会话数据,配置文件信息,内存使用和数据库查询的详细信息。 Joomla调试 以下是用于设置Joomla调试的简单步骤。 Step (1) - 进入System → Global Configuration ,如下面的屏幕所示。 接下来,单击Joomla Globa

  • Debug 输入sql语句,但不执行debug() Return: 开启Medoo调试模式 输出sql语句,不需要使用echo或其它方法。调试完成请移除此代码 $database->debug()->select("bccount", [ "user_name", "email"], [ "user_id[ 20]);// Will output:// SELECT "user_

  • Debug 输入sql语句,但不执行debug() Return: 开启Medoo调试模式 输出sql语句,不需要使用echo或其它方法。调试完成请移除此代码 $database->debug()->select("bccount", [ "user_name", "email"], [ "user_id[ 20]);// Will output:// SELECT "user_