I have been using Android Studio to develop my app since it's was released.
Everything works nice until recently, I have to debug together with checking the database file. Since I don't know how to see the database directly, When I debugged to generate the database file, I have to export the database file from my phone to the PC.
In order to do this, I have to open DDMS > File Explorer
. Once I open the DDMS, I have to reconnect the USB, and I lose my debug thread. After checking the database file, I have to close the DDMS and reconnect the USB again to get back to the debug mode.
It's just too complicated. Does anyone have a better way to do this in Android Studio (I know it's easier in Eclipse) ?
The simplest way is to Attach your device and run Android Studio Then From Tool Bar:
Another way is using Stetho library:
Add Stello dependency to your build.gradle:
compile 'com.facebook.stetho:stetho:1.5.0'
Put Following line on your onCreate() of your Application class or main Activity:
Stetho.initializeWithDefaults(this);
Connect your device, run the app and Enter the following site on Chrome:
chrome://inspect/#devices
and that is it. you can now explore your tables.
Note: it is recommended to remove the dependency before moving to production.
Open the Device File Explore Terminal at the Bottom of the Android Studio.
Open The folder named Data , then inside Data again open the Folder Data .
Scroll Down the list of folders and find the folder with your.package.name. Open folder your.package.name > Database. You get your.databaseName. Right Click your.databaseName and Save as to C:/your/Computer/Directory.
Go to C:/your/Computer/Directory open your.databaseName with DB SQLite
This is a VERY old question and my answer is similar to some answers above but done MUCH faster. The script below is for Mac but I'm sure someone can modify it for Windows.
1) Open Script Editor on your Mac (you can just search for Script Editor in Spotlight)
2) Copy and paste the text below and modify it with your SDK path, package name, etc. (see below)
3) Save the script!!
Thats's it! Just press the play button on top to get the updated database file, which will be on your desktop.
replace the following things in the script below:
path_to_my_sdk ==>> put full path to your sdk
my_package_name ==>> package name of your application
myDbName.db ==>> file name of your database
Hope this helps someone.
This might not be the answer you're looking for, but I don't have a better way for downloading DB from phone. What I will suggest is make sure you're using this mini-DDMS. It will be super hidden though if you don't click the very small camoflage box at the very bottom left of program. (tried to hover over it otherwise you might miss it.)
Also the drop down that says no filters (top right). It literally has a ton of different ways you can monitor different process/apps by PPID, name, and a lot more. I've always used this to monitor phone, but keep in mind I'm not doing the type of dev work that needs to be 120% positive the database isn't doing something out of the ordinary.
Hope it helps
I've put together a unix command-line automation of this process and put the code here:
https://github.com/elliptic1/Android-Sqlite3-Monitor
It's a shell script that takes the package name and database name as parameters, downloads the database file from the attached Android device, and runs the custom script against the downloaded file. Then, with a unix tool like 'watch', you can have a terminal window open with a periodically updating view of your database script output.
After going through all the solutions i will suggest
Use Stethos
Lets see how Simple it is
Add following dependencies in build.gradle file
Then go to you mainActivity onCreate method add following line
this would require you to
now while running app from android studio , Open Chrome and in address bar type
chrome://inspect/
in the resources tab >web SQL check the the database and table play with it in real time easily