从 Eclipse 检查 android sql 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3292818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Inspecting android sql database from Eclipse
提问by Christian
Is there a way to directly inspect an SQLite3 database in Android via Eclipse or do I have to do this via the shell?
有没有办法通过 Eclipse 直接检查 Android 中的 SQLite3 数据库,还是必须通过 shell 执行此操作?
回答by Brett
I don't know if you can inspect it from within eclipse but you can pull a copy of the database file from the DDMS perspective in the file explorer in folder
我不知道您是否可以从 eclipse 中检查它,但您可以从文件夹中的文件资源管理器中的 DDMS 角度提取数据库文件的副本
data->data->your.package.name->databases
which you can inspect with a free database manager such as sqlite studio
您可以使用免费的数据库管理器(例如 sqlite studio)进行检查
回答by Hamy
Unfortunately AFAIK you always have to use the shell currently. (Well, not quite. You can use DDMS in Eclipse to pull the database, but that's not much better than using the shell).
不幸的是,AFAIK 目前您总是必须使用 shell。(嗯,不完全是。您可以在 Eclipse 中使用 DDMS 来拉取数据库,但这并不比使用 shell 好多少)。
Basically you can either 1) pull the database file from the emulator / phone and then inspect it, or you can 2) manually run some SQL queries from inside the emulator/phone.
基本上,您可以 1) 从模拟器/手机中提取数据库文件然后检查它,或者您可以 2) 从模拟器/手机内部手动运行一些 SQL 查询。
For 1, I would recommend creating a script. Here is simple example
对于 1,我建议创建一个脚本。这是一个简单的例子
$ cat android_pull_db
#!sh
adb shell "chmod 777 /data/data/com.mypackage/databases/store.db"
adb pull /data/data/com.mypackage/databases/store.db
$
To create your own, paste the lines from #!... down to adb pull ... into a text file, and save it somewhere. Modify the package location and database filename. Make it executable, and add it to your path.
要创建自己的文件,请将 #!... 到 adb pull ... 的行粘贴到文本文件中,并将其保存在某处。修改包位置和数据库文件名。使其可执行,并将其添加到您的路径中。
For 2, just execute this:
对于 2,只需执行以下操作:
$ adb shell
$ cd /data/data/com.yourpackage/databases
$ sqlite3 your-db-file.db
> .help
回答by Gerard Humphries
http://sqlitebrowser.sourceforge.net/index.html
http://sqlitebrowser.sourceforge.net/index.html
This is a simple way of inspecting the contents of a database. Just use the DDMS to pull the database from the device and then open.
这是检查数据库内容的简单方法。只需使用 DDMS 从设备中提取数据库,然后打开即可。
回答by Takao Sumitomo
https://github.com/cattaka/TelnetSqlite/wiki
https://github.com/cattaka/TelnetSqlite/wiki
I made it this by following 3 step.
我通过以下 3 个步骤做到了这一点。
- Embed a small program
- Add code to kick the embedded program in the
Application.onCreate()
method - Execute the
telnet
and runSQL
via small program
- 嵌入小程序
- 在
Application.onCreate()
方法中添加代码踢内嵌程序 - 执行
telnet
并SQL
通过小程序运行
But it is not from Eclipse
. It uses telnet
or a sql editor
named RdbAssistant.
但它不是来自Eclipse
. 它使用telnet
或 一个sql editor
命名的RdbAssistant。