Wednesday, May 14, 2008

AIR Aplication Work Offline With Sqllite

We can make the AIR application work offline and synch with the database.

We can use sqllite databse for the offline display of data.
sqllite is just like mysql but it would create a *.db file in ur application folder
from where we can access the data.

A sample code for creating and executing the sqllite queries.

on creation complete we create a database contacts.

private function creationComplete():void
{
connection = new SQLConnection();
connection.open(File.applicationDirectory.resolvePath('contacts.db'));


var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS contacts (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT, outputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();

var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS offlineRequest (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();

}


This is very fast and effective too.

Cheers

Varun Rathore

No comments:

About Me