GUI way to access sqlite database on Android emulator - android

It there a more GUI oriented way (like SQL Server Management Studio or phpMyAdmin) of accessing sqlite database (view/change table structure, running test queries) in android emulator?
P.S. I know only one way to get there. This is through adb -> emulator shell -> sqlite

So far I found only partial solution.
With the help of file explorer in Android Monitor I export db file to host computer and then open database with SqliteBrowser.

Untested, but I just discovered sqlitestudio.pl (I'm unaffiliated with this product). They link to a video that shows this in action: https://www.youtube.com/watch?v=eFKLGsfpwNc.

Related

How to connect SQLite Studio to database via adb (emulator Android)

Do you know if there is a way to connected SQLite Studio (or similar) to the database via adb (emulator for Android), so I can see graphically my data via the laptop?
Thanks in advance
Actually you can use DbAndroid plugin (it's free, GPL'ed) that is shipped with SQLiteStudio (3.0.7). It will let you to connect to your android database without pulling or pushing the database file from/to an emulator or a device. It makes direct connection to the database in your application. Any changes to database made in SQLiteStudio will immediately be reflected in your running application.
Long story short - you add a jar file to your project as dependency, add few lines to inid/deinit the connector, then you add your database in SQLiteStudio and use it just as any other database.
There's a full manual on how to do it on SQLiteStudio's wiki page about this plugin: http://wiki.sqlitestudio.pl/index.php/DbAndroid
There's also a video demonstration on how to do it (also at that site). It's a bit too much to paste all of it here.
If you have any further problems with it, I'm happy to help (author here). You can also ask on SQLiteStudio's forum - I watch it often.
You can use Sqlite Studio to see your data: http://sqlitestudio.pl/
For internal storage you can get the database via adb:
adb pull /data/data/app_name/databases/db_name yourpath
If your database is in external just open it with Sqlite Studio.

View sqlite database on android

I am using android studio to develop my first android app.
I am plugging in my phone, and testing my app on there to test changes as I go.
I am using a sqlite database. How do I view this database, the tables, and the contents (rows) of those tables?
Upon Google searching I found that this can be done when you root your phone. But surely you dont have to root your phone to view your databases when your developing an app?
Update:
People are using terminology assuming knowledge. If you want me to copy a database, explain how, if you want me to use adb, explain what it is. Otherwise it means not much to me. Thanks
Pull the sqlite database named as XYZ.db from your simulator or device using adb shell command or GUI interface provided by the AndroidStudio. Then Open it using The Sqlite Browser. It's a killer app for sqlite browsing.
As android is shipped with the sqlite3, you could use command line to view the data base saved inside the device / emulator. Command reference is Listed Sqlite3 android command
If you feel lazy enough to discover how to pull files from emulator / device using adb pull, following answer may help you.
how to pull
At least in my case I needed to root my device. After that I installed SQLiteEditor. With this app you can modify and view your database. Or if you don't want to install a new app you can use a root explorer and enter directly into your installed app in the DB. Is inside /data/data/{yourapp}.
Copy your database to your system
Using copy or paste Or
Using adb pull command
Then Googled for sqlitestudio-2.1.4, download and run , browse your database ,,then you can see your database rows, column, value etc.

how to access my sqlite databsae via sqlite.exe?

I found out during the debug that my db is in:
/data/data/package-name/databases/...
how can i access this db from sqlite.exe (or with another tool) to run query / check what's in my tables to make sure that all fields are correct?
thanks very much! udi
You can use the sqlite3 util from a shell to an emulator.
Instructions here:
http://developer.android.com/guide/developing/tools/sqlite3.html
SQLite Database Browser is a freeware, public domain, open source visual tool used to create, design and edit database files compatible with SQLite. You can find it here.
As Ran suggested you can use the steps in the mentioned link , you need to use command prompt for it.
If you are using Eclipse IDE try opening DDMS and go to /data/data/package-name/databases/ there you can see your database , select the DB and Pull it on to your computer.
open the DB file with SQLLite3 database browser. You can alter your tables and push it back to the device using the IDE.
If the database is in the emulator, you can also do this from your PC command line: 'adb shell', then cd to the database location (/data/data/package_name/databases/) and run 'sqlite3 database.db'. I sometimes use this method for a quick table check, rather than copying the database from the emulator back to my PC.

Finding SQL Database File on Android Mobile Phone

I've created an application that uses an Android SQL database. Is there any way to find this database on the Mobile Phone that the Application is installed to?
Essentially I want to then use an SQL Database Viewer to look at all the rows?
root/data/data/package/databases/database
it should be in a file like that, in the emulator you can go straight to this using the file explorer in ddms, otherwise a rooted phone and ES file explorer
if you're using the emulator you can use the adb tool in the sdk-platform folder of the android install.
something like the following:
./adb shell
#sqlite3 /data/data/com.example.package/databases/database.db
you should then be able to do your queries.
If its on a phone, then try extract the database like above and use the sqlite3 tool to query that database.
A similar question has been answered here: https://stackoverflow.com/a/4556642/450534
The same answer provided there is:
If for whatever reason, you need to access the database on the phone, you must have root access (superuser in other words) on the phone. Then you will need a file explorer that uses root permission to give you access to the system files.
If all the above exists, then you will find the application database in:
/data/data/com.yourpackage.name/databases.

browse data in Android SQLite Database

Is there a way for an Android user to browse the SQLite databases on his/her phone and view the data in the databases?
I use the SoftTrace beta program a lot. It's great but has no way that I can find to download the data it tracks to a PC.
The database for a specific app lives in /data/data/[packagename]/databases
The packagename is the package you define in your manifest, for instance /data/data/org.vimtips.supacount/databases/counts.db.
You can view it with adb shell and type sqlite3 /data/data/org.vimtips.supacount/databases/counts.db
Or you can pull it from the device to look at it with a third party utility, with a command like adb pull /data/data/org.vimtips.supacount/databases/counts.db ..
This assumes you have permission to view the database, which you might not have if you didn't write the app yourself... but in that case, is it actually a programming question?
If you are using Eclipse, you can use a plugin called 'Questoid SQLite Browser' to browse the SQL Lite Database on your Android emulator:
Install the plugin
Restart eclipse
Start your emulator
Switch to DDMS
Open database with plugin (as #synic mentioned previously, the DB is located here e.g. /data/data/my_project/databases)
Here is a more detailed tutorial: http://www.tylerfrankenstein.com/browse-android-emulator-sqlite-database-eclipse
Here is the free method that worked for me on a phone that is not rooted. Credit goes to this SO answer.
Use adb backup -f backup.ab -noapk app.package.name
On Windows download the Android Backup Extractor jar found on SourceForge here, then run java -jar abe.jar unpack backup.ab extractedbackup.tar. On Linux you can follow the dd instructions from the answer I gave credit to in the beginning.
Download SQLite Database Browser from SourceForge here, then open the db file contained within extractedbackup.tar.
Personally, to make this process easier, I first added adb to my environment PATH. Then I made a backup folder where I store all of the files mentioned above. This keeps me from having to cd (change directory) all over the place.
The Questoid plugin appears to cost $9 and requires registering. Another alternative on Windows is to download the open-source public-domain SQLLite Browser (link below) and then pull the database from the phone. In Eclipse you can do this from the File Browser, going to the /data/data/[packagename]/databases directory on the phone or emulator, and clicking "Pull a File From The Device" in the top right. Save the database locally, then open with the SQLite Browser.
http://sourceforge.net/projects/sqlitedbrowser/
Actually the most available (yet still hacky) way of getting "live" results from a database while developing on emulator that I found is this:
Create a script to pull the database from emulator, something like this
#!/bin/bash
ANDROID_HOME=/path/to/sdk
ADB=$ANDROID_HOME/platform-tools/adb
REMOTE_DB_PATH=/data/data/com.yourpackage.name/databases/your_db
LOCAL_DB_PATH=.
while true; do
echo copying DB...
`$ADB pull $REMOTE_DB_PATH $LOCAL_DB_PATH`
sleep 3
done
Run it.
Install SQLite Manager plugin for Firefox
Open your local copy of the database (which is constantly overridden by the running script from step 1)
Enter your SQL:
Select File->Reconnect
Click Run SQL
The key trick is that reconnecting does not reset SQL entered on step 4 (as it does, for example, in SQLite Browser), so you can repeat steps 5,6 to see "live" results from your android database.
Note that this only works for emulator, it won't work for a real device (even a rooted one).
You can view you database from your app using this library . https://github.com/sanathp/DatabaseManager_For_Android
With this library you can manage your app SQLite database from you app itself.
you can view the tables in your app database , update ,delete, insert rows to your tables
Its a single java activity file ,just add the java file to your source folder.When the development is done remove the java file from your src folder thats it .
It helped me a lot .Hope it helps you too .
You can view the 1 minute demo here : http://youtu.be/P5vpaGoBlBY
If you were lucky enough to get IntelliJ Ultimate then you can plug the device in, open 'Database' tab on the right, click +, select SQLite. The rest is trivial.
One thing to keep in mind with it is that you have to keep clicking "Synchronize" button on the database (or on selected table) to see the changes made externally, which is very annoying.
See this answer. You can use Stetho library from Facebook and then just browser you database from Chrome :)

Categories

Resources