简体   繁体   中英

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 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

从谷歌播放下载此应用程序将帮助您在Android上安装sqlite3 https://play.google.com/store/apps/details?id=ptSoft.util.sqlite3forroot

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.

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 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/ )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM