I’ve recently written an AIR time tracking application that uses the Harvest & Coopapp APIs. The code and AIR application can be found on the harvestcoop project page on Google Code.
Harvest does provide an iPhone application and also a Harvest Widget for Mac OS X & MS Vista. I decided to create an AIR application so that users on operating systems that don’t have widget support can do their time tracking from the comfort of their own desktops.
The harvestcoop AIR application currently works with Harvest accounts that have widget support.
I’ll be presenting on the PureMVC framework next week (February 26) at the Vancouver Flash Platform February Meetup.
Here are the links to the presentation’s slides, sample application and code.
The Adobe AIR runtime includes a SQLite database so that you can create data driven applications.
The following are the default locations for the SQLite database:
Mac OS X:
C:\Documents and Settings\<userName>\Application Data\<applicationName>\Local Store\<databaseFileName>.db
Adobe AIR 1.5 introduces a feature to encrypt the SQLite database so that you can secure the contents of database. This is could come in handy if you are writing an application that stores information such as customer contact data.
The Open method and the OpenAsync method of the SQLConnection class include an encryptionKey parameter; this parameter tells AIR to encrypt the database file.
The code sample below shows you how to create / open an encrypted SQLite database. Links to an example application & code can be found at the end of this article.
private var dbConn:SQLConnection;
private var dbFile:File;
private var dbKey:ByteArray;
private function init():void
dbKey = Encryption.retrieveKey();
dbFile = File.applicationStorageDirectory.resolvePath("EncryptionExample.db");
dbConn = new SQLConnection();
// by passing in the dbKey variable as the encryptionKey parameter we are telling AIR to encrypt the SQLite database
dbConn.openAsync(dbFile, SQLMode.CREATE, null, false, 1024, dbKey);
Let’s take a look at the Encryption class to see how the dbKey ByteArray is created. The dbKey value is assigned the return value of the retrieveKey method from the Encryption class. The retrieveKey method checks to see if a key already exists in the application’s EncryptedLocalStore. If the key already exists the retrieveKey method will return the existing key, however if the key does not exist; the generateKey method is called to create a key.
The generateKey method uses the as3crypto library’s Random type to create a key. This key is required to read & write to the encrypted database.
public class Encryption
private static var _key:ByteArray;
private static function generateKey():void
// create key - write to encrypted local store
_key = new ByteArray();
var random:Random = new Random();
public static function retrieveKey():ByteArray
// try to retrieve key from encrypted local store
_key = flash.data.EncryptedLocalStore.getItem("key");
// if no key found in encrypted local store - create a key
if (_key == null)
After you’ve created the encrypted database you can navigate to the database file and try to open it. The database file will not open in your database browser application since the actual database file has been encrypted.
Here are the download links to the example application & code.