我看到Ionic2支持SqlStorage并且仅用于表创建,我不知道如何将预填充的sqlite db与SqlStorage一起使用。 有人能帮我解决这个问题吗? 提前致谢!!
最佳答案
创建存储时,可以传入选项对象
let storage = new Storage(SqlStorage, options);
SqlStorage 服务支持以下选项:
let options = {
name: '__ionicstorage', // the name of the database
backupFlag: SqlStorage.BACKUP_LOCAL, // where to store the file
existingDatabase: false // load this as an existing database
};
因此,您应该将 existingDatabase
设置为 true,确保 name
与您的数据库匹配,并将 backupFlag
设置为指向正确的数据库位置。
相关文档在这里: http://ionicframework.com/docs/v2/api/platform/storage/SqlStorage/
源代码也很容易理解:https://github.com/driftyco/ionic/blob/2.0/ionic/platform/storage/sql.ts
关于android - 如何在 Ionic2 中使用预填充的 SQLite 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35352724/