Using a SQLite database in Flex Mobile applications

SQLite in Flex MobileWhen working with local data in mobile applications you might want to consider a SQLite database. Those are especially useful when working with large amount of data that you want to filter at runtime.

Flex Mobile projects can simply take advantage of SQLite support in the Adobe AIR runtime. You could certainly write it from scratch – meaning you create a File instance and SQLConnection, set up event listeners, wait for the connection to open and set up a SQLStatement with a SQL query and more event listeners.

For most uses though there is a much easier approach using some simple SQLite wrapper classes myself and Robert Turrall wrote a while ago.


Just to illustrate how easy these wrapper classes make things for you when writing Flex Mobile projects look at the code below. These two lines do everything you need to open a connection to your database file and select all the records.

[cc lang=”mxml”]


You can see that using the open event on the SQLite tag we can wire it up to automatically run the query that selects all the records from our database.

The only thing left to do is pass the result of the database query to a component to display it in our mobile application. In this case I’ll be using a List component and assigning the data property of the query instance when the result event fires

[cc lang=”mxml”]


Running the code above will query the database for all records and show it in the List component.

In a more advanced application you would set up more Query tags to correspond to different queries or maybe updating or deleting records from the database. Have fun!


4 thoughts on “Using a SQLite database in Flex Mobile applications

  1. Nice article!

    SQLite is really easy to work with Flex, thanks for sharing 😉


  2. Andre says:

    Thanks for sharing this helpful article!!

  3. Marcio says:

    Hi, Peter!

    May you help me? I got an error message.

    [unable to load SWC SQLiteWrapper.swc]

    There is a link to it on library path.

    Thanks a lot

  4. rick21 says:

    please, can you provide the project, sir..?

    or explanation step by step including library etc.

Comments are closed.