an-rahulpandey / cordova-plugin-dbcopy

Copy SQLite Database from www folder to default app database location
Apache License 2.0
89 stars 47 forks source link

Cannot copy db on Android #17

Closed rfajarachmad closed 8 years ago

rfajarachmad commented 9 years ago

Hi @an-rahulpandey thank you for this awesome plugin, but I found an issue when using function sqlDB.copy(). I have a code like below :

console.log('Copying database'); window.plugins.sqlDB.copy("myDB.db", function() {
console.log('Opening database'); db = $cordovaSQLite.openDB("myDB.db");

  console.log('Testing query');
  MyObj.count("").then(function(result) {
    console.error("Count Result: " + JSON.stringify(result));
  })
}, function(error) {
  console.error("There was an error copying the database: " + error);
  db = $cordovaSQLite.openDB("myDB.db");

});

when I run the application and watch the logcat. it looks like the application never execute $cordovaSQLite.openDB("myDB.db"); because I only see the console log 'Copying database' I didn't see the console log 'Opening database' and also for error message.

I am guessing there is a problem during copy db process but I didn't know what the error is. Could you please give me an advice ?? thanks.

an-rahulpandey commented 9 years ago

Have you put the db file inside www folder?

rfajarachmad commented 9 years ago

I have put the db file under www folder, I still didn't have any idea how solve this but I tried another way to open the database and It worked. Currently I am using this syntax :

window.sqlitePlugin.openDatabase( {name: "myDb.db", createFromLocation: 1} );