views:

61

answers:

2

Hi there, I'm trying to copy my SQLite file that is used in my Air app to user's selected directory using

var fileSaveDest:FileReference = new FileReference();
fileSaveDest.save(dbWorkedFile,'Inventory.DB');

dbWorkedFile is a File

dbWorkedFile = File.documentsDirectory.resolvePath("Inventory.db");

I tried this but the saved file isn't a valid SQLite file.

Also, I was wondering whether it's possible to embed SQLite to Air? If so how can I import and export the database?

Many thanks

A: 

There is a short article describing how to include some SQLLite files in an AIR application on Adobe website (cookbooks section).

Cornel Creanga
Yes, I'm aware of that. In fact, that was where I started. Now, I just need to save that database file somewhere the users choose.
Pii
A: 

In the end I couldn't get FileReference.save() to work so I go with the regular File's browseForSave()

dbWorkedFile.addEventListener(Event.SELECT, savingDatabase);
dbWorkedFile.browseForSave('Specify save location');

private function savingDatabase(event:Event):void
{
    var selectedFile:File = File(event.target);
    //To ensure the file is still loaded
    dbWorkedFile = File.applicationStorageDirectory.resolvePath("Inventory.db");
    dbWorkedFile.copyTo(selectedFile, true);
}
Pii