- slide 1 of 3
Here in Spain (where I live), the Android community is very strong and most developers know each other. This library was created by Spanish developers: Javier Pacheco (javielinux), creator of the Android application “AndAndo”, and Javier Ros Moreno.
The AndroidDataFramework Library helps us to create and manage SQLite Databases in a very easy way. It is still in development, but the 1.0 version is out, so it is pretty stable.
In the How to work with Android Databases I introduced the SQLite databases and how to work with them. But I left in the air a way to create a Database with tables and records.
Now in the following articles I will explain how to do it in the “all life way” or using this library. Let's start!
- slide 2 of 3
First of all, we need to get the library, so we must go to the library code page, and download it. Yes it is in Spanish, but it's also very intuitive and easy to follow, just download the com.android.DataFramework.jar file. Or if you want to have a look at the example provided you can download the Prueba DataFramework.tar.gz file.
Once we have the file downloaded we need to add it to our project.
Right click on the Android project in our Eclipse environment, Click on the Java Build Path in the left option tree, select the Libraries tab and click on the Add External JARs button. Look for the .jar file you have just downloaded and voilá! We have it in our Android project. I have used Eclipse Galileo (the last version) so I dont know if these steps (and the labels names) are the same in older versions. Just ask if you have any questions!
Once we have the .jar file in our Android project, lets see how to manage it.
This library uses XMLs to generate the tables and the “initial values” of these tables. We now need to create an xml file inside the “res/xml” (Resources) directory called tables.xml, it MUST be this name. In this xml file, we will store the tables and its structures. We will see this in other articles which will be more technical.
If we want to have some data introduced in a first instance, we can use the initialvalues_vversion.xml file, where vversion is the concatenation of the "v" character and the number of the version of the library, "initialvalues_v1.xml" could be an example.
- slide 3 of 3
Now we have seen a little introduction to this library, in further articles I will develop its functionality a bit deeper. For now, just keep in mind that there is an easy way to work with Android Sqlite databases!!