1.adb shell 指令
通過遠端shell指令來控制模拟器/裝置執行個體.
adb 提供了shell端,通過shell端你可以在模拟器或裝置上運作各種指令。這些指令以2進制的形式儲存在本地的模拟器或裝置的檔案系統中:
/system/bin/...
不管你是否完全進入到模拟器/裝置的adb遠端shell端,你都能
shell
指令來執行指令.
當沒有完全進入到遠端shell的時候,這樣使用
shell
指令來執行一條指令:
adb [-d|-e|-s {<serialNumber>}] shell <shellCommand>
在模拟器/裝置中不用遠端shell端時,這樣使用
shell
命 :
adb [-d|-e|-s {<serialNumber>}] shell
通過操作
CTRL+D
或
exit
就可以退出shell遠端連接配接.
下面一些就将告訴你更多的關于shell指令的知識.
通過遠端shell端運作sqllite3連接配接資料庫
通過adb遠端shell端,你可以通過Android軟sqlite3 指令程式來管理資料庫。
sqlite3
工具包含了許多使用指令,比如:
.dump
顯示表的内容,
.schema
可以顯示出已經存在的表空間的SQL CREATE結果集。Sqlite3還允許你遠端執行sql指令.
通過
sqlite3
, 按照前幾節的方法登陸模拟器的遠端shell端,然後啟動工具就可以使用
sqlite3
指令。當
sqlite3
啟動以後,你還可以指定你想檢視的資料庫的完整路徑。模拟器/裝置執行個體會在檔案夾中儲存SQLite3資料庫.
/data/data/<package_name>/databases/
.
示例如下:
$ adb -s emulator-5554 shell# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version 3.3.12Enter ".help" for instructions.... enter commands, then quit...sqlite> .exit
當你啟動sqlite3的時候,你就可以通過shell端發送
sqlite3
,指令了。用
exit
或
CTRL+D
退出adb遠端shell端.
PS. 如果同時連接配接多個裝置或模拟器,執行上述指令時,會報“error: more than one device and emulator” ,這時需要加 -s 參數,例如:adb -s emulator-5554 shell
注:
1.”emulator-5554″是裝置名稱,可執行adb devices指令檢視。
2.上述方法似乎隻在模拟器上可以正常使用,在真機上,似乎沒有權限。