In the previous tutorials we've learned about SQL and now have some basic knowledge about using SQLite databases in AIR applications. Now it is time for practice, and we are going to create a working contacts book application, where all items are stored in a SQLite database.
In this tutorial, we will just set everything up to be ready to code.
We'll need to create a List component, three buttons and 3 text fields. If you are using Flash IDE, you can simply drag the components from the component window to the stage and create textfields using the text tool.
We need to have one List component (for displaying all the items in the database) called itemList. We'll need one button for creating new items, called b_new. We'll 3 text fields with labels next to them - First name, Last name, Phone. The instance names of the text fields should be t_fname, t_lname, t_phone. Make sure that they are input fields (that can be edited by the user). Of course, it's not too likely to ever find a need in a databse like this - a database that stores first and last names of a person and their phone number and nothing else, but this is just for this tutorial series purpose, and can be easily changed to suit any other needs later.
Next to the text fields you need to have 2 more buttons - Save this item and Delete this item. We will later make it so that you need to have an item selected in the List for these two buttons to become available, and you need to edit at least one symbol in any of the text fields for the Save this item button to be available. If the user, for example, decides to edit the phone number of one person - the Save button becomes available. If the user clicks it - the item is updated in the database. If the user doesn't save the changes and then selects another user - he didnt update the item in the database so his changes weren't saved.
Here's a picture explaining how everything should be put, with the objects' instance names in red next to the objects:
As I said before, you will probably never need to just store peoples' names and phone numbers, but the purpose of this tutorial series is to learn how to work with SQL databases in AIR and have some experience in that. If you are just here for the code to create a SQLite database powered application, such as contact book, todo list, mp3 player with playlists, etc. - you can read this tutorial to fully understand the mechanics, and then you'll need to modify a few things here and there to suit your needs.
We have everything set up now. We'll start coding in the next part!
Thanks for reading!
Creating an AIR application with an SQLite database: Part 2
Creating an AIR application with an SQLite database: Part 3
Creating an AIR application with an SQLite database: Part 4