【问题标题】:Where install SQLiteAndroidDatabase.java file?在哪里安装 SQLiteAndroidDatabase.java 文件?
【发布时间】: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
  • pouchdbmongoDb之类的数据库,我没有pouchDb的经验,但是看起来像我很实用

标签: android sqlite cordova


【解决方案1】:

您是否尝试在浏览器中运行它?

在设备中它可以工作,但在浏览器中它不会!

【讨论】:

猜你喜欢
  • 2013-10-10
  • 1970-01-01
  • 2011-10-09
  • 1970-01-01
  • 2014-12-19
  • 2013-11-03
  • 2016-01-22
  • 1970-01-01
  • 2014-10-03
相关资源
最近更新 更多