zoukankan      html  css  js  c++  java
  • Android使用ADB命令和stetho查看app数据库

    一.使用ADB命令查看

    打开命令窗口,进入Android SDK目录下的platform-tools,执行命令:

    1.输入:在windows下: adb shell  在linux下: ./adb shell

    2.进入data/data:如果手机没有root,使用命令 run-as 包名 可以直接进入到/data/data下的包名下

    3.进入到databases: cd databases

    4.使用 ls 命令列出当前目录所有数据库

    5.使用 sqlite3 数据库名  打开数据库

    常用sqlite操作,注意在sql语句后面加上分号

    6.使用  .tables  查看该数据库中所有表

    7.使用  .schema 表名  查看表的创建语句

    8.使用  PRAGMA TABLE_INFO(表名)  查看表中所有列

    9.最后可以执行相应的sql语句

    note:如果想要adb命令在任何目录下都可以使用,只需要配置一下它的环境变量就可以了(按照配置JDK的方法)

    某些手机使用 run-as 包名 命令可能无法找到包名(没有解决),还有某些手机找不到 sqlite3 命令(没有解决)

    二.使用facebook的stetho

    1.在GitHub上搜索stetho,打开第一个facebook/stetho

    2.打开Android Studio的build.gradle(Module:app),在dependencies中输入

    compile 'com.facebook.stetho:stetho:1.3.1'

    右上方有个 sync now 点击即可同步

    3.在该app中新建一个类,代码如下:

    public class MyApplication extends Application {
      public void onCreate() {
        super.onCreate();
        Stetho.initializeWithDefaults(this);
      }
    }

    4.在manifests中配置application的name属性:

    android:name=".MyApplication"

    5.最后在chrome浏览器中输入网址

    chrome://inspect    (可能需要翻墙)

    6.将手机连接到电脑,运行一下app,会在Devices 下方显示该应用的包名,点击下面的inspect,选择Resources,WebSQL下即可以看到自己应用的数据库

  • 相关阅读:
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    微信小程序TodoList
    C语言88案例-找出数列中的最大值和最小值
    C语言88案例-使用指针的指针输出字符串
  • 原文地址:https://www.cnblogs.com/cxsy/p/5671409.html
Copyright © 2011-2022 走看看