1
votes

I am developing a phonegap iOS application, whose android version has already launched. We are using prepopulated database for loading the initial data to the application. This worked well for me in android application. But in iOS using native sqlite plugin, i dont know how to implement it. I tried following method Phonegap SQLite Plugin Pre-populated Database iOS But it didnt work for me.. What im always getting is a database undefined error when trying to get data using select query.. I used cordova versions 2.7,3.0,3.1 ,all showed the same error. Can any one please help me with this.. I really sit for a long time for solving this. Dont know what is wrong, may be the path or format of the db file Im using is the problem. Please guide me

2

2 Answers

1
votes

You dont need the SQLite plugin, just use the built-in WebSQL database, like so:

var db = window.openDatabase("test", "1.0", "Test DB", 1000000);

and then run multiple INSERT queries to insert your default data.

Docs here: http://docs.phonegap.com/en/3.1.0/cordova_storage_storage.md.html#Storage

0
votes

Though this question is old... thought it might help someone to post a current solution - found in 2017. (Since PhoneGap has changed, older solutions no longer will work or be accepted on the Android and Apple app markets.) I worked on this problem for a long time - the issue is you want to import a pre-populated database - which there are not alot of easy solutions for. I found the best and easiest - and currently just about the ONLY - solution to be LiteHelpers CORDOVA-SQLITE-EXT (https://github.com/litehelpers/cordova-sqlite-ext)

I have added this in to my app and it is working well. I had to switch away from PhoneGap though - and use CORDOVA - but it is working for me.