You can use a plugin for this.
To install, use the command: cordova plugin add link
In order to use the Bank anywhere in my code, I created a variable named DB at the top of the index.js page, getting more or less the beginning of the page:
var db;
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
db = window.sqlitePlugin.openDatabase({name: "DB"});
db.transaction(function(tx) {
// Cria a Tabela "tabela_testes"
tx.executeSql('CREATE TABLE IF NOT EXISTS tabela_teste (id integer primary key, titulo text)');
// Adiciona um elemento a tabela
tx.executeSql("INSERT INTO tabela_teste (titulo) VALUES (?)", ["Meu primeiro post."]);
// Faz uma busca na tabela
tx.executeSql("SELECT * FROM tabela_teste;", [], function(tx, res) {
alert("Quantidade Resultados: " + res.rows.length);
for (var i = 0;i<res.rows.length;i++){
alert("Linha "+i+": "+res.rows.item(i).titulo);
}
});
});
To make a query in any part of the Application even outside the index.js page, simply use the DB variable and the query you want as in the above code.
Source: link