【发布时间】:2015-04-27 23:39:48
【问题描述】:
我正在尝试在我的 Phonegap 应用程序中使用 Cordova-sqlite-storage
我在我的应用程序页面中包含了SQLitePlugin.js,但是当我执行文档演示代码时,它在控制台中返回此错误消息:
[console.log] OPEN database: Database
[console.log] new transaction is waiting for open operation
[console.log] OPEN database: Database failed. aborting any pending transactions
[console.log] Could not open database
这是执行的代码:
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase("Database", "1.0", "Demo", -1);
db.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS test_table');
tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) {
console.log("res.rows.length: " + res.rows.length + " -- should be 1");
console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
});
}, function(e) {
console.log("ERROR: " + e.message);
});
});
}
在文档中是这样写的:
Install SQLiteAndroidDatabase.java and SQLitePlugin.java from src/android/io/liteglue into src/io/liteglue subdirectory
但我在我的项目中找不到src 文件夹
【问题讨论】:
-
您找到解决方案了吗?
-
还没有,我保存在
localStorage,但也许这可以帮助你pouchdb.com -
pouchdb是mongoDb之类的数据库,我没有pouchDb的经验,但是看起来像我很实用