FITC ’08 – Synchronizing Desktop Data with AIR and SQLite
Posted by Steve Lounsbury on April 21st, 2008
Live blogging presentation by Sean Voisen
To develop with AIR you need to know AS3. AIR has a built in SQLite database and you can use it to store data on the client.
You can synchronize data with the client so that you can use that data while offline. This leads to faster startup times, making things easily exportable and makes working with large datasets easier.
There are a few sync strategies:
- Manual Sync
- good for small amounts of data, requires a button to be pushed, easy to implement, but user can forget to do it.
- Background sync
- user doesn’t need to know about it, uses a timer, server can push data to the client (AIR tech: Livecycle data services)
Question you need to answer: who is the master, the client or server? You need to know who to trust when data collide.
Design of your code is important, aka Design Patterns (yeah man!)
Design Pattern: Brett Rampata, Adobe XD: gives the user a nice heads up view and can use both manual and background sync, shows connection availability.
Update: Link to Brett Rampata’s design pattern from above.
Demo of Paypal Desktop AIR App.
Demo of Paypal Desktop AIR App. 2.5 months of development time (one dev, one designer)
SQLite
- embedded database, stored in a single flat file, supports views, transactions and triggers
- Adobe added some types to the SQLite db to support AIR app development
AIR and SQLite
- supports synchronous and asynchronous connections.
- synchronous will stop the app while the query returns data.
- asynchronous will run in the background and uses an event listener to let you know when everything is done (nice and clean).
- supports prepared statements and named parameters in queries, and you shouldn’t use string concatenation (nice!)
- better performance over and above string concatenation because AS compiler will cache query and optimize for you.
- supports results paging.
Connection detection in AIR
- AIR will let you know when you have an internet connection available.
- Event will only tell you when things have changed, not if you are connected or not. You have to figure out if the change event means you are connected (ping some site, etc).
- Can use the service monitoring library which will let you know if a URL is available.
Action Script Programming strategies
- Use a DAO to abstract your SQL from your app. They are singletons (only allow one object to exist at a time) which handle the DB interfacing.
- Use “CREATE TABLE IF NOT EXISTS” so that you aren’t destroying your tables on each startup.
Demo “Library” App Available on Sean’s site
Resources:
coenraets.org
peterelst.org
probertson.com
xd.adobe.com








