How can I browse the SQLite database that I am creating in my app on my Android myTouch phone?
When I log in through adb shell, sqlite3 gives me a permission denied. Is there another way to check if my database and tables are actually being created, and if rows are being inserted?
I am not able to use the emulator, since it doesn't play videos etc. very well that is the main feature of my app, so I can only test on phone.
The entire database is a single file, so via the DDMS view in Eclipse or via the command line you can pull that file from the phone. You can then use SQLite DataBase Browser to view the contents, for example.
Using this library you can browse your SQLite database directly from your application
https://github.com/sanathp/DatabaseManager_For_Android
Its a single java activity file ,just add the java file to your source folder you can view the tables in your app database , update ,delete, insert rows to you table .Everything from your app.
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
Related
I am developping an Android apllication i wich i have an sqlite database which i want to extract the file (.db) to manage it with a manager (like sqlitemanager for example).
For that, i searched in many sites and the answer of the "how question" was the same, it consists of the following steps ( from http://forums.xamarin.com/discussion/4991/copy-sqlite-db-into-android-app ) :
1) Open the Android-sdk-windows
2) then open the tools
3) then ddms open
4) Dalvik Debug Monitor is open
5) then Device -> File Explorer.
6) data/data/your_project_package/files/your_database_file.db
7) copy your_database_file.db and open sqlite manager
I have followed these steps normally but my problem is that my data folder is empty !!, it does contain any another folder, and am getting this although i installed the application on the device, so i do not know what is the problem source.
I will be gratefull for any help
Thanks.
In the image below,Let if com.android.browser is the package name of your application then your database will be created in the db folder (not in the image ) as a sibling of lib.
Note: While working with sqlite database in android,I came to know that the created database will not show up even after the create statement for the tables are executed.They(the databases) are visible only in the DDMS file explorer, when some row is inserted in the table.So make sure you are performing some insertion before you start dealing with the database.
I created a app and added some tables, columns and some info in it and i want to check it, how do i do it?
Switch to DDMS perpective(Window > Open Perpective > DDMS).
Find out your database's db file in file explorer. Select it.
Export it by clicking on the button in the top right corner of the UI.(ie; Pull the file from from the device)
Use SQLiteman to view the data.
Hope it helps.
If you are running your app on the phone, you cant access your internal storage unless it is rooted. If that is your case simply run the app on a virtual device, then go to DDMS perspective, from there data/data/yourapplication/database/urdb.db then pull the db on the your computer and explore it with the tools stated above.
you can query the database from your android code to do this.
check the link http://codinglookseasy.blogspot.in/2012/08/sqlite-database.html where you can find creating table , inserting data into tables and retrieving it . Or use SQLite Database Browser http://sqlitebrowser.sourceforge.net/ to check the values without using the code
use Sqlite Database Browser tool to see the your Sqlite database.
Go to the DDMS and export your application database and open this database in Sqlite Database Browser
This post on how to access sqlite database on Android, will help you out. There is one mozilla plugin which can also help you to see the database.
I believe that Motodev Studio allows for database browsing.
http://developer.motorola.com/tools/motodevstudio/?utm_campaign=mhp01092012&utm_source=mhp&utm_medium=mws
Or you could just export the database to your desktop, for example, and then browse it with the Firefox SQLite plugin.
i have created a db in the phone and have inserted some values in it as well. now there is a large excel sheet which contains several more records that need to be inserted.
i am trying to find the db file in the phone so as to use sql lite db tool to upload some data in it. but the folder is empty.
can any one suggest or guide.
thanks
If you are on a real phone the /data folder will appear empty unless you have root access. An application like root explorer can allow you access to these folders (with the proper permissions). This probably isn't what you want to/should do.
If you are on an emulator you can use the file explorer in eclipse to browse your phones data/data/package folders and copy your database to and from the emulator quickly (or use adb shell commands).
Are you just doing this to test something? You should have your application insert the data you want, or create your own SQLite database and package it with your application. If you externally modify your database like this, reinstalling the application - or installing it on a different device - would result in an application still using your old/unmodified database.
i can access the my sqlite db using adb shell commands in my emulator. But can not do the same for my HTC Desire phone. it throws some permission denied messages. is there any possible to access those database for debugging purpose. Any Idea?
Thanks in Advance.
You can also type the following in to the command prompt/terminal
If your app package was com.example.dbtest and the database was called sqlite.db
adb shell
run-as com.example.dbtest
cat databases/sqlite.db > /sdcard/sqlite.db
exit
exit
adb pull /sdcard/sqlite.db /path/to/place/file
(if you leave the last parameter blank, it will be placed in the same directory as adb)
This does not require root and be scripted to remove any file from your apps.
You could also use a stream reader and writer to copy it to the sdcard. Do not copy it row by row as barmaley suggested as this may mask errors.
I can see only 2 options:
Get root access to your device
Write special procedure, which will copy your database to SD card (just record by record using SQLite API)
you dont need to rootor export you db . you can manage you android database directly from your apps using the below library
https://github.com/sanathp/DatabaseManager_For_Android
Its a single java activity file ,just add the java file to your source folder you can view the tables in your app database , update ,delete, insert rows to you table .Everything from your app.
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
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 :)