引言:
一直使用Eclipse开发Android。DDMS下有一个explorer可以查看data/data下各应用的数据,其中就包括database。但是这种方法只能导出来看,很不方便,于是就想到直接在adb shell里使用SqLite3命令查看更加方便。
cmd命令基础:
常用命令:
dir 显示文件列表
cls 清屏
cd 切换目录
ls 显示文件列表,cmd无效,adb 有效
windows应用命令,直接输入应用名字即可打开程序: (列举几个)
mspaint打开画图板
notepad打开记事本
explorer打开资源管理器
calc 启动计算器
命令快捷键:
ESC:清除当前命令行;
F7:显示命令历史记录,以图形列表窗的形式给出所有曾经输入的命令,并可用上下箭头键选择再次执行该命令。
F8:搜索命令的历史记录,循环显示所有曾经输入的命令,直到按下回车键为止;
F9:按编号选择命令,以图形对话框方式要求您输入命令所对应的编号(从0开始),并将该命令显示在屏幕上
Ctrl+H:删除光标左边的一个字符;
Ctrl+C Ctrl+Break,强行中止命令执行
Ctrl+M:表示回车确认键;
Alt+F7:清除所有曾经输入的命令历史记录
Alt+PrintScreen:截取屏幕上当前命令窗里的内容。
SqLite命令举例:
先切换到相关目录
adb shell
cd data/data/com.example.demo1023/databases
ls 会显示当前应用下所有的数据库:
sqlite3 db1.db 即进入到db1.db数据库就可以执行相关的sqlite3的命令了
.help ;查看sqlite3设置命令帮助:
|
sqlite> .help
.help
.backup ?DB? FILE Backup DB (default "main") to FILE
.bail ON|OFF Stop after hitting an error. Default OFF
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in an SQL text format
If TABLE specified,only dump tables matching
LIKE pattern TABLE.
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.
With no args,it turns EXPLAIN on.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.import FILE TABLE Import data from FILE into TABLE
.indices ?TABLE? Show names of all indices
If TABLE specified,only show indices for tables
matching LIKE pattern TABLE.
.log FILE|off Turn logging on or off. FILE can be stderr/stdout
.mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
.nullvalue STRING Print STRING in place of NULL values
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.restore ?DB? FILE Restore content of DB (default "main") from FILE
.schema ?TABLE? Show the CREATE statements
If TABLE specified,only show tables matching
LIKE pattern TABLE.
.separator STRING Change separator used by output mode and .import
.show Show the current values for various settings
CREATE TABLE user(_id INTEGER PRIMARY KEYAUTOINCREMENT,name VARCHAR(20),price INTEGER);