【发布时间】:2016-04-12 22:02:49
【问题描述】:
我有一个 sqlite 数据库 test_db.db 我保存在 www 文件夹中,我正在使用 cordova cli 在本地计算机上构建 android 应用程序。
当我尝试打开数据库时,它打开的是新数据库,而不是访问预填充的数据库。
我使用以下代码对此进行了测试。
// Open the existing database
var db = window.sqlitePlugin.openDatabase({ name : "test_db.db" });
db.transaction(function (tx) {
alert("database opened");
var _strQuery = "select * from mst_users;";
tx.executeSql(_strQuery, [], function (tx, res) {
alert("Populated Successfully with " + res.rows.length + " Records.");
}, CommonError);
}, CommonError, DoNothing);
每次我收到表 mst_users 不存在但它存在于预填充的数据库中的错误。
我已经尝试了各种方法来实现这一点,但仍然卡住了。我想访问预填充数据库中的数据。
非常感谢任何帮助..
【问题讨论】:
标签: android database sqlite cordova