开发者

How to install or get access to sqlite3 from adb shell

I need a way to install or somehow get access to sqlite3 in the adb shell. I have rooted my device.

I've tried to find an answer but the closed I could come is: Why do I get a "sqlite3: not found" error on a rooted Nexus One when I try to open a database using the adb shell?

But I don't think it's good idea to push my windows sqlite3.exe on a linux system?

So is it possible to install the sqlite3 terminal browser somehow?

[SOLUTION]

From the different comments and some asking around at #android-dev (irc), I found a solution. First I copied the database file to my desktop. But fist I had to install BusyBox, because cp isn't included?!? After that ran I into the problem that I couldn't pull or push from anywhere but /sdcard/ . I could then use /sdcard/ as a "middle station" and pull/push my db.

Then I got exhausted! I really had to have my sqlite terminal explore. Then I got the idea to start the emulator pull开发者_如何学Go the sqlite binary from /system/xbin/sqlite3. Then remount /system with rw:

# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

and push sqlite to the /sdcard/, and from there copy it to /system/xbin/

Now it works :D


Download this app from google play will help you install sqlite3 on android https://play.google.com/store/apps/details?id=ptSoft.util.sqlite3forroot


You don't need root to pull the database from your device. Simply run the following commands:

adb shell run-as <package-name> "cp databases/<db_name>.db /sdcard/ && exit"
adb pull /sdcard/<db_name>.db ~/Downloads/

From there, you can use sqlite3 for whatever operating system you're using (http://www.sqlite.org/download.html), or a sqlite browser such as "DB Browser for SQLite" (http://sqlitebrowser.org/)


I use Rajath's technique... Adb "Pull" the db from the emulator/device, work on it, then adb "push" it back onto/into the emulator device.

also: I use the free SQLite Editor from the Android Market. I have not rooted my LG Ally and therefor can only edit database tables on my sdcard with SQLite Editor.

Rajath suggests using the adb to push and pull the databases to and from the emulator/device. The work on the database with the windows (or whatever) sqlite3 program you have. He does not suggest pusing the windows sqlite3 onto the Android device, IMHO.

I note that java/android "query()" sends actual SQL commands programmacitacly to ones program with user input. I conclude that sqlite3 is in Android somewhere.

When using the emulator Dev Tools is available, and way down at the bottom of the list is the Terminal Emulator. This allows exploration of file structure of Android in the emulator. However using "adb shell" from the PC has root permissions.

good luck. cactus mitch


You can do this with adb shell without issue.

In terminal or CMD (assuming you have the ADB path set and your phone has ROOT) type:

  1. $ adb shell
  2. $ cd data/data/com.nameofyourpackage/databases/
  3. $ ls to find the name of your database
  4. $ sqlite3 nameofyourdb.db

Then you can use .tables .schema to see the data you need to create the appropriate query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜