如何在 Android 设备上查看 SQLite 数据库? [英] How do I view the SQLite database on an Android device?
问题描述
我在 SQLite 数据库中有一组数据.我需要在设备上查看数据库.我该怎么做?
I have a set of data in an SQLite database. I need to view the database on a device. How do I do that?
我已经检查了 ddms 模式.文件资源管理器中的数据为空.
I have checked in ddms mode. The data in file explorer is empty.
推荐答案
这里是分步说明(主要来自其他答案的组合).这甚至适用于未植根的设备.
Here are step-by-step instructions (mostly taken from a combination of the other answers). This works even on devices that are not rooted.
连接您的设备并在调试模式下启动应用程序.
Connect your device and launch the application in debug mode.
您可能想使用 adb -d shell "run-as com.yourpackge.name ls/data/data/com.yourpackge.name/databases/"
来查看数据库文件名是.
You may want to use adb -d shell "run-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/"
to see what the database filename is.
注意: com.yourpackge.name
是您的应用程序包名称.您可以从清单文件中获取它.
Notice: com.yourpackge.name
is your application package name. You can get it from the manifest file.
将数据库文件从应用程序文件夹复制到 SD 卡.
Copy the database file from your application folder to your SD card.
adb -d shell "run-as com.yourpackge.name cat/data/data/com.yourpackge.name/databases/filename.sqlite >/sdcard/filename.sqlite"
注意:filename.sqlite 是您创建数据库时使用的数据库名称
Notice: filename.sqlite is your database name you used when you created the database
将数据库文件拉到你的机器上:
Pull the database files to your machine:
adb pull/sdcard/filename.sqlite
这会将数据库从 SD 卡复制到 ADB 所在的位置.
This will copy the database from the SD card to the place where your ADB exist.
安装 Firefox SQLite 管理器:https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
打开 Firefox SQLite 管理器(工具->SQLite 管理器)并打开上面第 3 步中的数据库文件.
Open Firefox SQLite Manager (Tools->SQLite Manager) and open your database file from step 3 above.
享受吧!
这篇关于如何在 Android 设备上查看 SQLite 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!