日期:2014-05-16  浏览次数:20680 次

android-adb调试与sqlite远程shell(android调试桥)

1)

adb(android调试桥)是android工具包中的一个特殊工具,必须有一个正在运行的模拟器或连接了一个android设备,adb才能工作。以下为在powershell中的测试:

PS D:\android-sdk-windows\platform-tools> .\adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached

2)查看当前可用的虚拟设备

PS D:\android-sdk-windows\tools> .\android list avd
Available Android Virtual Devices:

如果没有设备,通过SDK Manager配置一下



配置完毕后,可以看到虚拟设备的结果

PS D:\android-sdk-windows\tools> .\android list avd
Available Android Virtual Devices:
??? Name: mytest
??? Path: C:\Users\deepfuture\.android\avd\mytest.avd
? Target: Android 2.2 (API level 8)
??? Skin: WVGA800
? Sdcard: 32M
PS D:\android-sdk-windows\tools>


3)手动启动模拟器

?PS D:\android-sdk-windows\tools> .\emulator -avd mytest



?

4)再开一个powershell窗口

用adb进行调试

先查看是否检测到虚拟设备正在运行

PS D:\android-sdk-windows\platform-tools> .\adb devices
List of devices attached
emulator-5554?? device

然后连接设备

PS D:\android-sdk-windows\platform-tools> .\adb shell

查看设备当前目录
# ls
ls
config
cache
sdcard
acct
mnt
d
etc
system
sys
sbin
proc
init.rc
init.goldfish.rc
init
default.prop
data
root
dev

5)查看可操作的命令集

# ls /system/bin
ls /system/bin
run-as
gdbserver
showlease
ifconfig
pppd
kill
applypatch_static
ndc
fsck_msdos
netstat
ps
netd
sendevent
sync
flash_image
servicemanager
schedtest
rild
updater
chmod
ioctl
input
notify

6)查看整体目录结构

# cd /
cd /
# ls -l
ls -l
dr-x------ root???? root????????????? 2011-05-09 14:18 config
drwxrwx--- system?? cache???????????? 2011-05-09 14:18 cache
lrwxrwxrwx root???? root????????????? 2011-05-09 14:18 sdcard -> /mnt/sdcard
drwxr-xr-x root???? root????????????? 2011-05-09 14:18 acct
drwxrwxr-x root???? system??????????? 2011-05-09 14:18 mnt
lrwxrwxrwx root???? root????????????? 2011-05-09 14:18 d -> /sys/kernel/debug
lrwxrwxrwx root???? root????????????? 2011-05-09 14:18 etc -> /system/etc
drwxr-xr-x root???? root????????????? 2010-06-30 21:06 system
drwxr-xr-x root???? root????????????? 1970-01-01 00:00 sys
drwxr-x--- root???? root????????????? 1970-01-01 00:00 sbin
dr-xr-xr-x root???? root????????????? 1970-01-01 00:00 proc
-rwxr-x--- root???? root??????? 12995 1970-01-01 00:00 init.rc
-rwxr-x--- root???? root???????? 1677 1970-01-01 00:00 init.goldfish.rc
-rwxr-x--- root???? root?????? 107412 1970-01-01 00:00 init
-rw-r--r-- root???? root????????? 118 1970-01-01 00:00 default.prop
drwxrwx--x system?? system??????????? 2011-05-09 14:20 data
drwx------ root???? root????????????? 2010-01-28 00:59 root
drwxr-xr-x root???? root????????????? 2011-05-09 14:19 dev

7)查看设备安装的包列表

# ls /data/data
ls /data/data
com.android.gesture.builder
com.example.android.apis
com.example.android.softkeyboard
com.example.android.livecubes
com.android.term
com.android.email
com.android.sdksetup
com.svox.pico

8)查看包列表中的各包所含数据库文件:*.db为sqlite数据库

# ls? /data/data/com.android.providers.contacts/databases
ls? /data/data/com.android.providers.contacts/databases
contacts2.db
#

9)登录sqlite,直接操作

比如查看数据库中的表

# sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db
sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
.tables
_sync_state?????????????????????