SQLite does not initialize Cordova / Phonegap

0

I added the cordova-sqlite-storage plugin in my phonegap project but when I create the database it does not create and does not initialize.

document.addEventListener("deviceready", onDeviceReady, false);
var db;
function onDeviceReady() {      
    var db = window.sqlitePlugin.openDatabase({name:"app.db"});
}
function erroCB1(err) {
    alert('erro no banco: ' + err.message + '\n Codigo: ' + err.code);
}
function sucecessCB1(err) {
    alert('Sucesso');
}

I can use websql without problems, however sqlite does not give a sign of life, besides adding the cordova-sqlite-storage plugin do I need to do something else?

    
asked by anonymous 27.04.2016 / 21:19

1 answer

0

Try this:

document.addEventListener("deviceready", onDeviceReady, false);
var db;

function onDeviceReady() {
  db = window.sqlitePlugin.openDatabase({
      name: 'my.db',
      location: 'default'
    },
    function(sucesso) {
      alert("Funcionou!");
    }, function(erro) {
      alert("Nao abriu ==> " + JSON.stringify(erro));
    });
}
    
27.04.2016 / 22:56