0

I'm new to ionic app development.
Going to develop a dictionary app with ionic, angular and sqlite.
SQLite db file is already prepared with required tables and the app needs to be deployed with the db file.

As the first step how can I read data from db file?

Should I use SQLite https://ionicframework.com/docs/native/sqlite
or SQLite Porter 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));
          });

I tried above coding but it gives me 404 not found error on Android Studio emulator.

1 Answer 1

1

The import file should be .sql not .db. Since SqliteDbCopy is having an copying issue with capacitor, I used SQLitePorter

Final solution is to use capacitor, SQLitePorter and .sql file to import data.

Sign up to request clarification or add additional context in comments.

1 Comment

Where you have a supplementary question, please ask that as a new question. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.