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

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?

On the Android emulator, sqlite3 is in /system/xbin. There is no /system/xbin on a Nexus One (Android 2.2). Hence, I suspect that sqlite3 is not installed on the Nexus One.

sqlite3: not found

Some manufacturers deliver the devices without sqlite being installed on them. You can copy the sqlite program though from a emulator to your device if the device has an arm processor.

  1. Start the emulator and use the adb command from the platform-tools in android-sdk

    adb pull /system/xbin/sqlite3

  2. Mount the system partition of your device read/write after this tutorial:

    http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html

  3. Use the adb command to copy the sqlite3 file to your device

    adb push sqlite3 /system/xbin/

After you reboot your device the sqlite3 command should work.

Edit (copy from linked page - in the case link becomes invalid). The instructions for step 2 are:

adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

"Replace /dev/block/mtdblock3 & /system with appropriate device path and mount point, as obtained from cat /proc/mounts"

How to install or get access to sqlite3 from adb shell

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

Why does the SQLite 3 command using the Android ADB shell return permission denied ?

The files are read protected. You need to root your phone or use the emulator.

How to use ADB in Android Studio to view an SQLite DB

Easiest Way: Connect to Sqlite3 via ADB Shell

I haven't found any way to do that in Android Studio, but I access the db with a remote shell instead of pulling the file each time.

Find all info here:
http://developer.android.com/tools/help/sqlite3.html

1- Go to your platform-tools folder in a command prompt

2- Enter the command adb devices to get the list of your devices

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb devices
List of devices attached
emulator-xxxx device

3- Connect a shell to your device:

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell

4a- You can bypass this step on rooted device

run-as <your-package-name> 

4b- Navigate to the folder containing your db file:

cd data/data/<your-package-name>/databases/

5- run sqlite3 to connect to your db:

sqlite3 <your-db-name>.db

6- run sqlite3 commands that you like eg:

Select * from table1 where ...;

Note: Find more commands to run below.

SQLite cheatsheet

There are a few steps to see the tables in an SQLite database:

  1. List the tables in your database:

    .tables
  2. List how the table looks:

    .schema tablename
  3. Print the entire table:

    SELECT * FROM tablename;
  4. List all of the available SQLite prompt commands:

    .help


Related Topics



Leave a reply



Submit