I've been trying to get my cordova app working on a device with a prefilled database (using SQLite and DbCopy) and I've encountered a problem following a tutorial. When using ionic run android, to run the application on a device, the first time it works perfect, but when I run it for the second time db is null and it won't work again until I remove the Database and start all over again.
var db = null;
angular.module("alterApp", ["ionic", "ngCordova"])
.run(function ($ionicPlatform, $cordovaSQLite) {
$ionicPlatform.ready(function(){
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar){
StatusBar.styleDefault();
}
window.plugins.sqlDB.copy("prefilledDB.db", function() {
db = $cordovaSQLite.openDB({ name: "prefilledDB.db" });
}, function(error) {
db = $cordovaSQLite.openDB({ name: "prefilledDB.db" });
});
});
})
Any thoughts ? If there is another way to use a prefilled database with Ionic then I could use it too.
Thanks in advance and sorry for my English.
Aucun commentaire:
Enregistrer un commentaire