Guide to Using Google Android Databases

Written by:  • Edited by: Simon Hill
Updated May 3, 2011
• Related Guides: File System | Android | Google Android Programming

In this Google Android programming guide we take a look at how to work with Android internal databases. Android supports an SQLite database system, keep reading to learn more.

Internal Databases

For this Google Android instructional guide we will work with Android internal DataBases. Android supports a SQLite database system.

In Android, data from applications is stored in a database system. Every application has its own database. The point of this Article is to get to the database file, in other articles we will see how to work with them inside the Apps.

Hint!As far as I could research, we can only have database files from the Emulator. In real devices they may be locked. So this would be useful to know more about the Android internal system.

Lets have a look at one of this databases.

To access the database we have to go to the DDMS perspective in Eclipse once an emulator is running. As I explained in one of my past articles on the left side panel we can find the “File Explorer”, here we can surf around the Android file system. We can see 3 folders:

-Data -> Application data

-SDCard -> File system inside the SD card (if any).

-System-> Core file system.

In the “data/data” path, we will find a list of packages, most of these packages store data in the internal database. Lets have a look towards the “com.android.alarmclock” package. Inside of it, we can find the folder “databases” and inside of this folder, the “alarms.db” file.

We pull the file from the device, click on the “disk-and-arrow” icon. Now, we have the database file out of the emulator. Its time to see whats inside on it.

For this purpose we will need an external tool to open the .db file.

Looking at http://www.sqlite.org/cvstrac/wiki?p=ManagementTools we can find lot of tools to work with SQLlite. I prefer GPL-licensed ones, like:

http://sqliteman.com/

or

http://sqlitestudio.one.pl/index.rvt

I will use QSLitestudio for the purpose of this article.

Now we can find the alarm.db file via our computer from the QSLitestudio and then open it.

It should look something like this.

capture7
click to enlarge

Here we can see the tables, fields and values of the “alarm.db”. In this case, we can see the hours that the alarm is set to in the Emulator.

Want to know more?

This is the simplest way to achieve the views we need within our databases, and this simple tutorial end this series of articles related to "Android external tools". Soon, we will start developing working applications. Stay Tuned.


Comments

Showing all 19 comments
 
MUNIRASU Feb 8, 2011 12:00 AM
Database creation
Hi , can anyone explain how to develope internal database in android Applications.?..

Regards
Munirasu
Rick Jan 20, 2011 6:26 PM
Works in emulator not on device
My app's db is created fine on the emulator but does not get created when testing on the device. The getWritableDatabase call does not call onCreate. Anyone have any ideas? It's not a matter of if the db already exist, the db is never created when running on the device.
Aher Shweta Jan 11, 2011 4:29 AM
File format
hello,
how can i start with creating a database which stores files with a particular format(e.g DWG) and not storing the files with any other formats
Plz help me with this issue in android
kruti Jan 5, 2011 12:50 AM
hi
how to use sqlite studio with android?
usman Nov 13, 2010 8:12 AM
database on sd card
can anybdy tell me how can i create a db on sd card.I have been searching for this like a month now. Jbeer man please tell me
Jose Apr 5, 2010 12:22 PM
Create Database
I would like to know if I can make the structure of the database apart of the aplication, not in the first run of it..... because I will use somes tables.....

Also I would like to know if I can use "views" in the database with android.....

Good info!!!

saludos y gracias..
Jbeerdev Mar 28, 2010 1:40 PM
RE: Guide to Using Google Android Databases
This topic is big enough to write about it. I will do it soon: How to handle databases in Android.
Mike Mar 23, 2010 3:08 PM
Recent calls
How can I delete just one call from my recent calls without having to delete all of them.
Jimmy Mar 17, 2010 6:59 AM
Database
Hi !. I am new to android. Can u please tell me the right way to create a database and insert values dynamically in it. I tried a lot of examples given on internet. But none of them help me a lot. It will be great if u help me using some simple and complete example.

Thanks in advance.
Jbeerdev Dec 18, 2009 2:38 AM
RE: Guide to Using Google Android Databases
Hi Sam!

How do you contruct your listView? Do you use a BaseAdapter? or just a string array?

Here is some info about ListViews:

http://developer.android.com/reference/android/widget/ListView.html

But let me know how do you use it.
Sam Dec 17, 2009 6:50 PM
Listview
I need to store a string value from a list view item into a database, how would you get the listviews string value?
Jbeerdev Nov 20, 2009 4:00 AM
More Articles
If you are interested I have here a list of artilces I have written so far:

http://sites.google.com/site/josebcortes/articulos/the-bright-hub

and some code snippets too:

http://sites.google.com/site/josebcortes/articulos/code-snippets

(not much of them... but I just started to gather them)
Kiran Nov 20, 2009 3:51 AM
Create android databases
That is very useful article. Looking forward for many more.....
priboltik Nov 15, 2009 6:38 AM
Internal Functions of DB
oy.... yeah))))
strange, what i didn't see it early....
thanks!!!!
Jbeerdev Nov 15, 2009 6:31 AM
About creating Queries
About creating your own queries, you have to use the

rawQuery

method from the SQLiteDatabase objet. There you can use the queries you want :)
Jbeerdev Nov 15, 2009 6:30 AM
About SQLite Functions
Hi Priboltik.

In this page you will find all SQlite information!

http://www.sqlite.org/

Here more specifically:

http://www.sqlite.org/lang_corefunc.html

:)
priboltik Nov 15, 2009 6:25 AM
Internal Functions of DB
Hi. Thanks for a articles.
I want to know, if i want to use some SQLite standart functions like 'max' or 'avg'. How can i create such query????

P.S. Sorry for my English....
Jbeerdev Oct 9, 2009 4:05 AM
Create Android Databases
Creating Android Databases can be very simple. I will wirte about how to do it, in diferente ways, using diferent libraries.
sara Oct 9, 2009 3:55 AM
Create Android databases
Nice !!!!!!!!

Try this too,
<b>Create Android databases</b>
 
blog comments powered by Disqus
Email to a friend