从你连接你设备的远程shell或者你的主机,你能使用sqlite3命令行程序来管理通过Android应用程序创建的SQLite数据库。sqlite3工具包含许多有用的命令,例如.dump打印表的内容,和.schema来打印一个存在的表的SQL CREATE语句。这个工具也能使你迅速的执行SQLite命令。
从一个远程shell使用sqlite3:
通过输入下面的命令进入一个远程shell:
adb [-d|-e|-s {<serialNumber>}] shell
在远程shell,通过输入下面的命令启动sqlite3工具:
sqlite3
你也能选择指定你想探索的数据的完成路径。模拟器/设备在/data/data/<package_name>/databases/.目录中保存SQLite3数据库。
一旦你调用sqlite3,你能在shell中运行sqlite3命令。为了退出并返回adb远程shell,输入exit或者按CTRL+D。
这里是一个例子:
$ adb -s emulator-5554 shell
# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version 3.3.12
Enter ".help" for instructions
.... enter commands, then quit...
# sqlite> .exit
为了使用本地的sqlite3,替代在shell内,把数据文件从设备中拷贝出来,并启动sqlite3:
从你的设备复制数据库文件到你的主机:
adb pull <database-file-on-device>
从/tools目录启动sqlite3工具,指定数据库文件:
sqlite3 <database-file-on-host>
新技术,新未来!欢迎大家关注
“1024工场”微信服务号
,时刻关注我们的最新的技术讯息!
(甭客气!尽情的扫描或者长按!)