This question already has an answer here:
- Debugging sqlite database on the device 15 answers
I have a set of data in an SQLite database. I need to view the database on a device. How do I do that?
I have checked in ddms mode. The data in file explorer is empty.
The best way I found so far is using the Android-Debug-Database tool.
Its incredibly simple to use and setup, just add the dependence and connect to the device database's interface via web. No need to root the phone or adding activities or whatsoever. Here are the steps:
STEP 1
Add the following dependency to your app's Gradle file and run the application.
STEP 2
Open your browser and visit your phone's IP address on port 8080. The URL should be like:
http://YOUR_PHONE_IP_ADDRESS:8080
. You will be presented with the following:NOTE: You can also always get the debug address URL from your code by calling the method
DebugDB.getAddressLog();
To get my phone's IP I currently use Ping Tools, but there are a lot of alternatives.
STEP 3
That's it!
More details in the official documentation: https://github.com/amitshekhariitbhu/Android-Debug-Database
You can do this:
adb shell
cd /go/to/databases
sqlite3 database.db
sqlite>
prompt, type.tables
. This will give you all the tables in the database.db file.select * from table1;
First post (https://stackoverflow.com/a/21151598/4244605) does not working for me.
I wrote own script for get DB file from device. Without root. Working OK.
~/android-sdk/platform-tools
)../getDB.sh -p <packageName>
for get name of databases.Usage:
./getDB.sh -p <packageName> -n <name of DB> -s <store in mobile device>
for get DB file to this (where script is executed) directory.I recommend you set filename of DB as *.sqlite and open it with Firefox addon: SQLite Manager.
(It's a long time, when i have written something in Bash. You can edit this code.)
step 1 Copy this class in your package
step 2 put the following code in your class which extends SQLiteOpenHelper.
step 3 register in manifest
step 4
If you are using a real device, and it is not rooted, then it is not possible to see your database in
FileExplorer
, because, due to some security reason, that folder is locked in the Android system. And if you are using it in an emulator you will find it inFileExplorer
, /data/data/your package name/databases/yourdatabse.db.try facebook Stetho.
Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
https://github.com/facebook/stetho