05-09-2011 01:10 AM
I am trying to copy my Sqlite database file from application private directory to user accessible documents directory. Here is my code:
// closing db connection
dbConnection.close();
// clearing the db file variable
dbFile = null;
// new handle on the same db file
dbFile = File.applicationStorageDirectory.resolvePath("mydb .db");
// copy to documents directory
dbFile.copyTo(File.documentsDirectory);
When I try to run the code on the device I get:
Error: Error #3012: Cannot delete file or directory. at flash.filesystem::File/copyTo()
I have <action>access_shared</action> in the blackberry-tablet.xml
What file or directory it is trying to delete? I am just copying the file.
Cannot figure out what is the problem.
Solved! Go to Solution.
05-09-2011 01:41 AM
There's an example on the Adobe AIR help-page:
var original = air.File.documentsDirectory.resolvePath("AIR Test/test.txt");
var newFile = air.File.documentsDirectory.resolvePath("AIR Test/copy.txt");
original.copyTo(newFile, true); // true stands for overwrite!
So you have to specify the new filename too not only the directory.
05-09-2011 09:51 AM - edited 05-09-2011 09:52 AM
This is how I've done it:
Sample:
// Init database
var embededSessionDB:File = File.applicationDirectory.resolvePath("assets/db.s qlite");
var writeSessionDB:File = File.applicationStorageDirectory.resolvePath("asse ts/db.sqlite");
// If a writable DB doesn't exist, we then copy it into the app folder so it's writteable
if (!writeSessionDB.exists) {
embededSessionDB.copyTo(writeSessionDB);
}
var dbFile:File = writeSessionDB;
dbConnection.open(dbFile);
And best of all, no need for "access_shared"