I've successfully backup my .db file from file:///data/data/my.package.name/databases/data.db
into file:///storage/sdcard0/data.db
using fileEntry.copyTo()
, but have problem on restore db file back to app. If I copy backup .db file to file:///android_asset/www/
I got FileError error code 1000, and if I copy the file to file:///data/data/my.package.name/databases/
directly, there is no error occurred, but my app still reading a empty database after restore done.
My restore db code:
function performDBRestore() {
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function(fileSystem) {
window.resolveLocalFileSystemURL(
"file:///storage/sdcard0/data.db",
function(fileEntry) {
window.resolveLocalFileSystemURI(
"file:///data/data/my.package.name/databases/",
function(directoryEntry) {
fileEntry.copyTo(directoryEntry, "data.db",
function (fileEntry) {
console.log("Restore success!");
},
function (error) { //no error, but db still empty while open
console.log("Restore fail!");
}
);
},
function(error) {
//if I copy backup file to "file:///android_asset/www/", I got errCode 1000 here
}
);
},
function (error) {
//some error handling....
}
);
},
function(error) {
//some error handling....
}
);
}
Any idea? thanks a lot.
Aucun commentaire:
Enregistrer un commentaire