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.
Start the emulator and use the
adb
command from theplatform-tools
in android-sdkadb pull /system/xbin/sqlite3
Mount the system partition of your device read/write after this tutorial:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Use the
adb
command to copy the sqlite3 file to your deviceadb 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:
List the tables in your database:
.tables
List how the table looks:
.schema tablename
Print the entire table:
SELECT * FROM tablename;
List all of the available SQLite prompt commands:
.help
Related Topics
Using Jaxb with Google Android
How to Style the Drawerarrowtoggle from Android Appcompat V7 21 Library
Android: Using Webview Outside an Activity Context
How to Scale Bitmap to Screen Size
Getting Access to Media Player Cache
Register Application Class in Manifest
Neither User 10102 Nor Current Process Has Android.Permission.Read_Phone_State
Android Runtimeexception: Unable to Instantiate the Service
Android: Set Color of Checkbox
How to Make Grid-View Horizontally Scrollable in Android
How to Detect When a User Plugs Headset on Android Device? (Opposite of Action_Audio_Becoming_Noisy)
How to Turn Speaker On/Off Programmatically in Android 4.0
Android: Cursoradapter, Listview and Checkbox
Set Edittext Digits Programmatically
Adding Google Play Services Version to Your App's Manifest