I am using SQLite as suggested from this page http://ionicframework.com/docs/v2/native/sqlite/
but how do I know where is the *.db file location, since it set as default?
How to set a specific db file path to location?
*but how do I know where is the .db file location, since it set as default?
The default location is the www folder, so you donāt need to do anything other than placing your db file on www folder and setting location='defalut'
on SQLite. Image showing my DB inside www folder
In my case iām using a pre-populated database , donāt know if itās what you want.
The plugin iām using is (GitHub - brodybits/cordova-sqlite-ext: A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/macOS/Windows with REGEXP (Android/macOS/iOS) and pre-populated databases (Android/iOS/macOS/Windows)). Install with ionic plugin add cordova-sqlite-ext --save
Basically this what i do:
First import SQLite
import { SQLite } from āionic-nativeā;
Options to open database, name is the name of the database i already have, if you donāt have any database it should be the name to give to your DB.
let options = { name: āMTS.dbā, location: ādefaultā, createFromLocation: 1 };
Create the connection
this.storage = new SQLite();
Open database and execute a simple query (my DB contains a table called stations)
this.storage.openDatabase(options).then((su) => { this.storage.executeSql('SELECT * FROM stations', {}).then((res) => {console.log(JSON.stringify(res))}, (err) => { console.error('Unable to execute sql: ', err); });
What version of Ionic are you using? In Ionic 4 did not work because it recreates the folder www.
In that case it was Ionic 2. I havenāt used Ionic since Ionic 2. I have an example with Ionic 3 in Github ionic3-PreDB. But i havenāt updated it in a while.
Thanks man, I saw this example that you posted. But for me only version 4 same.
Did you ever figure this out? I am a little lost and would love some help.