Android 如何使用PhoneGap5.4和SQLite插件

Android 如何使用PhoneGap5.4和SQLite插件,android,sqlite,cordova,phonegap-plugins,Android,Sqlite,Cordova,Phonegap Plugins,我正在尝试使用SQLite插件将PhoneGap5.4与Android上的SQLite连接起来[ 首先,我创建项目并使用Phonegap CLI导航到它 $phonegap create sqlite-demo $cd sqlite-demo 之后,我运行以下命令安装SQLite插件: $phonegap plugin add https://github.com/litehelpers/Cordova-sqlite-storage --save 最后,我使用下面的代码来测试[index.j

我正在尝试使用SQLite插件将PhoneGap5.4与Android上的SQLite连接起来[

首先,我创建项目并使用Phonegap CLI导航到它

$phonegap create sqlite-demo
$cd sqlite-demo
之后,我运行以下命令安装SQLite插件:

$phonegap plugin add https://github.com/litehelpers/Cordova-sqlite-storage --save
最后,我使用下面的代码来测试[index.js文件],但什么也没发生:

var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);        
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
    app.receivedEvent('deviceready');
    var db = window.sqlitePlugin.openDatabase({name: "my.db"}, 
    function() {
        alert('Connected');
    },
    function(err) {
        alert('Error');
    });
},
// Update DOM on a Received Event
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    console.log('Received Event: ' + id);
}
};
在PhoneGap API[网站]上,我没有看到任何关于存储或数据库的部分


有什么解决方案吗?

解决方案是:只需像这样编写数据操作代码,因为存储模块是自动注入到项目中的