One good feature in Adobe's AIR, the platform for developing rich Internet
apps is a database engine that runs within AIR's runtime environment. Since all
the database files are stored locally, there is no need of an external database
connection. This also implies that persistent application data can be stored
conveniently on the local drive. The local database is stored as a single file
in the computer's file system. The runtime is responsible for creation,
retrieval and manipulation of data in this database file. In the following
implementation, we will be using synchronous mode of execution to create RIAs
with AIR.
Implementation
Let's start with installation of AIR SDK. This can be downloaded from
'www.adobe.com or you can also get it from this issue's DVD. Once extracted to a
folder, set the PATH environment variable. This can be done by adding reference
of extracted folder to it. In our case, we added the following path in the end
of PATH environment variable 'C:\AdobeAIRSDK\bin'. The bin folder present in SDK
contains ADL and ADT tools.AIR debug launcher or ADL is used to run applications
without packaging them, whereas AIR developer tool is for packaging your
application as an AIR file for distribution. One more important file that we
would be using in this implementation is 'AIRaliases.js' present in 'C:\AdobeAIRSDK
\frameworks\libs\air' folder. This file provides alias definition that allows
one to run 'ActionScript' runtime class i.e. air.FileStream, air.SQLDatabase
etc. To use this file, one needs to add following script reference in HTML page:
Start with creating a folder that contains three files: XML file (pcquest.xml),
HTML file (pcquest.html) and AIRaliases.js file as explained above. We will
start with the applications descriptor file (pcquest.xml). Here is the content
of this file along with explanation:
Direct Hit! |
Applies To: Web Developers USP: SQL like engine within AIR Primary Link: www.adobe.com Keywords: AIR |
Add the attribute that defines the namespace for AIR as shown. Last part
shows the version of AIR used:
Next line shows attribute to uniquely identify application:
One can also define version of the application as :
To define properties of the application window:
Now we have created the required descriptive file. Let's create a HTML page
that contains code to create database and then display that database. Here is
the code snippet showing the content of 'pcquest.html':
Before packaging, one can test the result of application using ADL. Simply move to application folder and type 'adl pcquest.xml' in command prompt. |
To check the results of the created application, open command prompt and move
to the application folder and type in the window:
Adl pcquest.xml
Finally one can easily package AIR application in just two steps, start with
creating certificate and key pair for application as shown here:
adt -certificate -cn SelfSigned 1024-RSA testCert.pfx
password
To create .air installer file, simply run following command, it will prompt
for password :
adt -package -storetype pkcs12 -keystore testCert.pfx
PCQUest.air pcquest.xml pcquest.html
Now one can distribute this application using PCQUest.air file. This shows
how web developers having SQL knowledge can use their SQL skills in easily
developing applications in AIR.