Chapter 10. Embedded SQL Database Programming

Adobe AIR doesn’t include only Flash Player to execute SWF content and only the WebKit engine to load HTML content and JavaScript. AIR also has an embedded version of the SQLite database engine that makes the runtime truly complete; SQLite gives developers the opportunity to store data locally offline and to do it via the same language they use to store data for web applications: SQL.

Widely used across platforms, SQLite is an open source, award-winning database engine that implements the SQL-92 specifications (http://www.sqlite.org/omitted.html).

SQLite in Adobe AIR gives applications the ability to persistently store data and easily manage it. This data can be stored locally in offline situations but then can be synchronized with network data store. With the 1.5 version of Adobe AIR, it isn’t possible, however, to natively connect to remote databases.

To be able to access, store, and manipulate data in a SQLite database in Adobe AIR, you first must create the database as a local file. Each database needs its own local file. The AIR SDKs contain the APIs you need to work with SQLite via ActionScript or JavaScript. For ActionScript code, SQL database classes are in the flash.data package, whereas for JavaScript, the classes can be directly instanced by using AIR aliases (you just have to import the AIRAliases.js file into your HTML document).

Creating a Database

Problem

You need to create a local database using SQLite.

Solution

Create a local ...

Get Adobe AIR 1.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.