2012-01-15 162 views
6

我想從我開發的android應用程序的命令行訪問SQLite數據庫。我輸入adb shell連接到設備,然後輸入sqlite3連接到數據庫。 sqlite3給我以下錯誤: /系統/ bin/sh:sqlite3:找不到從命令行訪問SQLite數據庫

+0

你是怎麼進入亞行後得到貝殼? – Yury 2012-01-15 21:32:01

+0

shell @ android:/ $ – JustCurious 2012-01-15 21:35:54

+0

它是一個設備還是仿真器? – Yury 2012-01-15 21:42:47

回答

0

嘗試鍵入「adb shell類型sqlite3」以查看sqlite3是否在您的設備中可用。

對於我的設備,它顯示如下

$ ADB殼型sqlite3的 - > sqlite3的是跟蹤別名/系統/ XBIN/sqlite3的

0
// Below code works on windows platform.. tried on windows 7 and windows 8 
// This is vb script code.. save with .vb extention. 
// any problems in saving.. please copy paste any vb file from ur system,take that second file ,open it with notepad and clear all contents, paste the below code as i did same. 
// double click to run file. output shown will ur all tables. and u can continue with  the own sql statements 

// note : works with only one emulator. many emulator are supported. 
// please dont try this code with mobile, you wont be able to access mobile database 

// start of script 


Set WshShell = WScript.CreateObject("WScript.Shell") 
// set ur path to platform tools in ur sdk 
strApp = "E:\Android\sdk\platform-tools" 

arrPath = Split(strApp, "\") 

For i = 0 to Ubound(arrPath) 
    strAppPath = strAppPath & arrPath(i) & "\" 
Next 



WshShell.CurrentDirectory = strAppPath 

WshShell.Run ("cmd.exe") 
WScript.Sleep 50 
WshShell.SendKeys "adb shell" 
WshShell.SendKeys "{ENTER}" 

// put ur package name and database name over here. please put ur db name with .db   extension 



WshShell.SendKeys "sqlite3 /data/data/package_name/databases/database_name" 
WshShell.SendKeys "{ENTER}" 
WshShell.SendKeys ".tables" 
WshShell.SendKeys "{ENTER}" 
Set objShell = Nothing 
// script ends 
+0

在創建一個vb文件之前取出所有註釋 – Sush 2013-03-22 08:53:26