如何查看android设备的数据库文件

587 阅读1分钟

1.确保手机的授权管理已经开启root权限

2.手机的/system/xbin/目录下有sqlite3工具,下载地址:sqlite3

adb push 本地路径 手机路径(或用root explorer转移sqlite3文件,权限均设定可读可写)

adb pull 手机路径 本地路径 (无权限直接从非sdcard路径到本地操作)

3.在终端执行adb shell进入linux脚本模式($),然后输入su获取root权限(#),这时候ls的目录就是手机的根目录结构

4.进入data/data/程序包/databases,这里就是sqlite的数据库文件了。

5.使用sqlite3 数据库名称,就可以打开对应数据库(sqlite>),并通过数据库语句进行查看。(可以通过输入.help查看具体使用方法)

.exit退出sqlite3编辑

.mode line一个比较好的查看布局

exit退出shell脚本模式

Run emulator on your local computer, then

localuser:~ localhostadb shell
shell@android:/ su shell@android:/ # cp /data/data/your.package.name/databases/your_database.db/mnt/shell/emulated/0/Download/your_database.db shell@android:/ # exit shell@android:/ exit
localuser:~ localhost adb pull /mnt/shell/emulated/0/Download/your_database.db ~/your_database.db

What it does is:

  1. Connects to the emulator
  2. Requests superuser permissions
  3. Copies the file that is only available to superuser to a public directory (Downloads in this case)
  4. Pulls the file from public folder (Downloads) to your local machine home directory; you can also perform this step from eclipse gui.