iursevla / ionic2-PreDB

Simple Ionic 2+ with pre-populated database starter project
The Unlicense
14 stars 4 forks source link

DB is empty. #2

Closed tuanbs closed 7 years ago

tuanbs commented 7 years ago

Hi I followed your code but when I opened DB, it is empty. How can I solve it? Thanks.

iursevla commented 7 years ago

Hi, Stil having the same issue? What version of ionic do you have?

tuanbs commented 7 years ago

I use Ionic v2, the latest one. Anyway, I solved it by using the sqlite-ext. Thanks.

iursevla commented 7 years ago

Yes you were supposed to use sqlite-ext plugin, otherwise it won't work. Any question ask away ;)

tuanbs commented 7 years ago

I mean I have to use the syntax of sqlite-ext to load the pre-populated DB: `declare var cordova: any; declare var window: any;

db = window.sqlitePlugin.openDatabase( { name: 'dbName.db', location: 'default', createFromLocation: 1 } ); ` Then it'll copy the pre-populated DB. Using the code in your repo will generate the empty DB:

import { SQLite } from 'ionic-native'; ... public storage: SQLite; ... private options = { name: "data.db", location: 'default', createFromLocation: 1 }; ... this.storage.openDatabase(this.options).then((success) => {...})

As far as I known this is an issue of ionic-native. Anyway, I tested it and found DB is empty and I don't know how you can get pre-populated DB using your code.

Cheers.

iursevla commented 7 years ago

@tuanbs Are you using an emulator or physical device? When i have some time i'll look at my code again to update it to the last Ionic 2 version.

iursevla commented 7 years ago

@tuanbs
I updated to the new version of ionic and with this i will keep most of my code. With some minor changes. I'll update the repo today.

iursevla commented 7 years ago

Updated version now available. Anything let me know.