views:

49

answers:

2

I apologize if this is a stupid question, nevertheless I need to ask. I am new to Android development and have gone through every single tutorial and reference provided. I have been doing great, with the exception of one stupid problem; I cannot find where the databases for some apps are stored.

For example I would like to build my own app that includes thousands of pre-made records from an established SQLite Database. As a reference I tried to use the "Searchable Dictionary" app from the provided programs in the Android SDK, but cannot find it.

I read that all databases are stored in /data/data//databases on the device, but I cannot find this location. So how would I access the database in Eclipse or anywhere else for that matter to set up my pre-configured database?

Thanks so much!

A: 

Assuming your package for your app is com.example.androidapp and the database name is db you can do the following:

adb shell

and then in the command line shell

cd /data/data/com.example.androidapp/databases
sqlite3 db

and then in the sqlite3 interface e.g.

.schema

or

SELECT * FROM tablename;

and so on.

Manfred Moser
Ok thank you that makes sense. I think my problem is that I cannot get the adb shell to run properly. It opens when I use the emulator or Android SDK but closes quickly. If I try to launch it manually from TOOLS -> AMD.exe it will not open. What am I missing with the getting the command screen to work?
Matt
I am not sure what you are using. On both Linux and Mac all I have to do is type adb shell in a command line window and I am in. Maybe you have to ensure your sdk is setup properly. There are screencasts for that on youtube..
Manfred Moser
Thanks for all your held Manfred, I did get the command functions to start working although I still am in the dark on using this type of approach. I am going to continue to read up and watch videos on how to execute the command functions to control the database.
Matt
A: 

not directly in eclipse, but sqlite db browser is petty nice http://sqlitebrowser.sourceforge.net/

Ben
Ben, I am already using the SqLite Browser and it is a great tool. My issue is rather that I would like to figure out how to open an already existing database from an Android Project in the SqLite Browser so I can edit and add to it. Do you know how I can do this?
Matt
Yes. If you go into the ddms perspective then into the file explorer you can then navigate to the / data/ data/com.myapp/ databases folder and pull that file down. You can then open it up in SQLite browser... hope this helps
Ben
Problem with that is that you are looking at a local copy of the database so you will not see any updates in the database while you debug. I found that working on the command line in adb shell is better for up to the debug breakpoint querying (and testing..).
Manfred Moser
Ben you are me hero - 3 days of frustration and with your help finally got the solution I was looking for! Thanks a million!
Matt
cool. glad i could help. go ahead and give my answer an up vote then :)
Ben
Will do as soon as I get some reputation - unfortunately I cant yet
Matt