Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre populate SQLite Database in iONIC Cordova iOS

I created the initial slide menu application using ionic.

I've a db file in my project, How can i access this.

I want to access the existing data base in my project and populate the data in my app.

I tried below plugins and other tutorials but I can't able to access the data base file.

https://github.com/litehelpers/cordova-sqlite-ext

Anyone can you please help and suggest me something in this. Thanks.

like image 442
Suthan M Avatar asked Jan 21 '26 11:01

Suthan M


1 Answers

To prepopulate your database you can do this :

Run these commands:

git clone https://github.com/nolanlawson/cordova-prepopulated-database-demo.git
cd cordova-prepopulated-database-demo
cordova plugin add cordova-plugin-file
cordova plugin add cordova-plugin-sqlite-2

Then to run on iOS:

cordova platform add ios
cordova run ios

Or to run on Android:

cordova platform add android
cordova run android

You have now a file called mydatabase.db in www/. This is a simple database, with the following structure:

>.schema
CREATE TABLE mytable (foo text, bar text);
>SELECT * FROM mytable;
hello|world

You just have to edit this file to populate the database as you wish !

More information on this github : https://github.com/nolanlawson/cordova-prepopulated-database-demo

Hope it will help you ;)

like image 50
Didi Avatar answered Jan 23 '26 01:01

Didi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!