0
我想要的PhoneGap 5.4使用SQLite在Android上使用SQLite,插件[https://github.com/litehelpers/Cordova-sqlite-storage]如何使用PhoneGap的5.4和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 [http://docs.phonegap.com/plugin-apis/]網站,我沒有看到有關存儲或數據庫的任何部分。
有沒有解決方法?