首页 文章

SQLite:openDatabase调用中现在必须使用数据库位置或iosDatabaseLocation值

提问于
浏览
0

我正在使用SQLite插件为Android和iOS的离子应用程序

插件:cordova插件添加https://github.com/litehelpers/Cordova-sqlite-storage.git

离子版:2.1.18

cordova版本:6.4.0

节点版本:4.5.0

这是我打开和创建数据库的代码

var db;
db = $cordovaSQLite.openDB({ name: "test.db", iosDatabaseLocation:'default'});
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS OfflineData (id integer primary key, imageUrl text, videoUrl text, head text, title text, descr text)");

但是我在Android设备上运行时遇到问题

ionic.bundle.min.js:150 Error: Database location or iosDatabaseLocation value is now mandatory in openDatabase call
at newSQLError (plugins/cordova-sqlite-storage/www/SQLitePlugin.js:26)
at Object.<anonymous> (plugins/cordova-sqlite-storage/www/SQLitePlugin.js:565)
at Object.openDatabase (plugins/cordova-sqlite-storage/www/SQLitePlugin.js:59)
at Object.openDB (ng-cordova.js:5176)

任何人都可以帮助我 .

1 回答

  • 0

    您只是指定iOS位置,但在Android上运行 .

    您需要检测正在运行的平台(使用Ionic的 Platform 类)并使用Android的 location 属性和iOS的 iosDatabaseLocation 属性 .

相关问题