Android SQLite App Development With Flash Builder And Flex

best android apps
Updated on November 30, 2013 Kevin Languedoc moreKevin is Software Developer with 20 years experience designing and building software applications including iOS and Android apps. Contact Author Adobe Flash Builder with either Flex (Adobe or Apache) is very fast and is optimized for mobile application development. Android Apps created with Flash Builder using Adobe Air and Adobe Flex (4.6 and earlier) or Apache Flex (4.8 and later) can be distributed as is through the Google Play Store and the Amazon App Store. The IDE also has utilities which allow you to sign and bundle your application for distribution in the Google Play Store. The whole process from project creation in the Eclipse based Flash Builder IDE to packaging your app for distribution is very easy and fast depending on the complexity of your app. To demonstrate the process of creating an Android application with a SQLite database. I will create a simple contact management app that we allow a user to enter contacts and save the information to a SQlite database. The app will also allow a use to view the stored contacts in a list.

The app will feature a tab based design; one of the contact editing and the other to view the contacts. The project will be built using Adobe Flash Builder 4.6 and corresponding SDK. Once the app is built and tested, I will provide the steps to do to package the app for deployment to the Google Play web Android web store. Select “New Flex mobile Project” from the File menu. Under “Project Location”, provide a Project name in the project creation utility. See corresponding screenshot in figure 1 (opposite). Select the Tabbed application project template. This will allow us to create a tab based Android app. Take a look at figure 2 in the adjacent screenshot for a visual guide. Under Server Settings and Build Paths accept the defaults and click “Finish” to create the initial project. Once the project is created and the project‘s main application file, AndroidSQLite.mxml, view code listing 1 below, is opened in the Visual Designer, select the target device from the drop down list. You work area of your screen should automatically adjust to the screen resolution of the selected device.

You can also use this list to test your app on several different devices. The Flash Builder 4.6 offers all the current device version on the market at the present time. You can add new device configurations as new models are introduced to the market. To add a new device , locate the Device configuration section in Preferences. The first part of this project involves developing the SQLite database interface, the Model and the Controller in the MVC design pattern. The code will include functions to setup and initialize the database, to insert new records and to select existing records. Once this code is complete, we will connect the ActionScript code to the mxml views in order to make the application complete. To start create a new folder inside of the Views folder. You right click on the View folder in the Project Explorer and select the new folder option in the context menu. For this example I named the folder "scripts".

Actionscript File to create a new script file in the folder. You can name it whatever you like. The first order of business is to define the import statements that we will use in our code. These classes include the SQLConnection which handles connections with the database. The SQLStatement as you may have guessed represents the query statements. The three following classes are to handle SQL success and failure events and the Events class handles any interaction with the components. The File class is used to interface with the database file. The ArrayCollection is a class to handle multi-dimensional arrays. Next define the global variables for the connection, statement and ArrayCollection. ] directive which will maintain state between calls to the variables. This function is called from the applicationComplete event of the TabbedViewNavigatorApplication main application element. The function creates the database using the File class and we use the OpenSync to open the database.