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
View contents of database file in Android Studio
Finally, i found a simplest solution which do not need to open the DDMS.
Actually, the solution is based on what @Distwo mentioned, but it don't have to be that complicated.
First, remember the path of your database file in the device, it should aways the same.
For example mine is:/data/data/com.XXX.module/databases/com.XXX.module.database
Second, execute this command which pulls your database file onto you PC
adb pull /data/data/com.XXX.module/databases/com.XXX.module.database /Users/somePathOnYourPC/
What you need to do is just copy and store this command, then you can use it again and again.
Third, if you got Permission Denied or something like that, just run adb root
before the previous command.
How to access my app's SQLite database in android device emulator for debugging
So i find this to be working:
adb root shell
adb shell
Then I'm able to navigate to my app's database folder and open it.
View SQLite database on device in Android Studio
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/adb.html#sqlite
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
4- 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
Source : This SO answer..
Adb pull from Android Studio and database not updated in SQLiteDatabaseBrowser 3.10.1
The .db file and the -shm file and the -wal file must be copied to the computer in order to see all the data.
Related Topics
Android: How to Get Value of an Attribute in Code
Safely Fixing: Javax.Net.Ssl.Sslpeerunverifiedexception: No Peer Certificate
A Way to Get Unlock Event in Android
Place 2 Textview Beside Each Other with 2Nd Textview Always Visible
Android - Timepicker Minutes to 15
Google Places API Request Denied for Android Autocomplete, Even with the Right API Key
Flutter Run Error:You Have Not Accepted the License Agreements
Error: Status{Statuscode=Developer_Error, Resolution=Null}
How to Scale Bitmap to Screen Size
Forcing the Soft Keyboard Open
Android - How to Get the Processname or Packagename by Using Pid
Programmatically Getting the Gateway and Subnet Mask Details
Android: Set Color of Checkbox
How to Tell If the Sdcard Is Mounted in Android
Multi Selection Spinner in Android Without Alertdialog
How to Get Sms Sent Confirmation for Each Contact/Person in Android