I am getting an error while connecting to Sqlite DB in android through command prompt.
Here are the steps I have followed:
Tried to conned to DB though Command Prompt :
D:\adt-bundle-windows-x86-20131030\adt-bundle-windows-x86-20131030\sdk\platform-tools> adb shell
adb shell
root@generic:/ # sqlite3 /data/data/package-name/databases/SampleDB.db
sqlite3 /data/data/package-name/databases/Samp
ant.encryptdata/databases/Samp <leDB.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
.tables
SQL Error: unable to open database "/data/data/com.congnizant.encryptdata/databases/SampleDB.db": unable to open database file
1|root@generic:/ #
Actually i want to post screenshot for better understanding but i dont know why its not working(may be becuase of my office firewall).
Permision for SampleDB is '-rw-rw----';
So where am I doing worng?
Note: The database is present having one sample table and i can read write data into that table.
I had similar below issue on android emulator:
**Issue:**
1)generic_x86:/ $ sqlite3 EmployeeRecords
SQLite version 3.9.2 2015-11-02 18:31:45
Enter ".help" for usage hints.
2)sqlite> select * from employee
...> ;
Error: unable to open database "EmployeeRecords": unable to open database file
**Solution**
1)C:\Users\Hpo\AppData\Local\Android\sdk\platform-tools>adb shell
2)generic_x86:/ $ exit
3)C:\Users\Hpo\AppData\Local\Android\sdk\platform-tools>adb root
4)C:\Users\Hpo\AppData\Local\Android\sdk\platform-tools>adb root restarting adbd as root
5)C:\Users\Hpo\AppData\Local\Android\sdk\platform-tools>adb shell
6)generic_x86:/ # cd /data/data/com.example.hpo.crud_myapplication/databases/
7)generic_x86:/data/data/com.example.hpo.crud_myapplication/databases #
sqlite3 EmployeeRecords
8)sqlite> select * from employee
...> ;
1|sachin|15000
and it's working.
It looks like my very same problem not long ago.
You may test something first. Once you're connected to the device with adb shell
, try ls data/data/<application_namespace_id>/databases/
. If it returns opendir failed, Permission denied
, it should be the same problem I had: ADB permissions issue. And here's what solved my problem:
Now, try again your commands. But once you enter adb shell
also enter su
to enable Super User mode. You should see a #
confirming your shell on Super User mode.
If you have only one device connected, it should work now. Otherwise, you should also confirm if you're connected to the right device by listing your devices first running adb devices
and connecting to right one adb -d <device_reference_here> shell
.
You'll probably also need your phone rooted to do any of this.
Hope it helps. Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With