【发布时间】:2021-03-11 01:09:03
【问题描述】:
我是 ionic 应用程序开发的新手。
打算用 ionic、angular 和 sqlite 开发一个字典应用程序。
SQLite db 文件已准备好所需的表,应用程序需要使用 db 文件进行部署。
作为第一步,我如何从 db 文件中读取数据?
我应该使用
SQLite https://ionicframework.com/docs/native/sqlite
或者
SQLite 搬运工 https://ionicframework.com/docs/native/sqlite-porter
let db = (<any>window).openDatabase('dictionary', '1.0', 'dictionary', 1 * 1024);
this.http.get('../assets/database/dictionary.db', { responseType: 'text' })
.subscribe(sql => {
this.sqlitePorter.importSqlToDb(db, 'select * from terms')
.then(() => console.log('Imported'))
.catch(e => console.error(e));
}, error => {
console.log('error: ' + JSON.stringify(error));
});
我尝试了上面的编码,但它在 Android Studio 模拟器上给了我 404 not found 错误。
【问题讨论】:
标签: angular sqlite ionic-framework