0

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

Pii
  • 301
  • 4
  • 15

2 Answers2

1

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
  • 301
  • 4
  • 15
0

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

Cornel Creanga
  • 5,311
  • 1
  • 22
  • 28
  • 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 Aug 16 '10 at 00:39