TAGS :Viewed: 6 - Published at: a few seconds ago

[ What database to use with PhoneGap ]

I am creating my first mobile app using Phonegap and I am not sure what database to use with it. I have read a few articles and am finding it hard to decide on which is best to use. Two of the ones mentioned most seem to be MongoDB or SQLite

Because PhoneGap needs Nodejs, I thought that MongoDB would be a good option but is that too robust? I am familar with Mongo but don't want to choose it just because it is convenient, I would prefer to use what is best.

The app will hopefully store information both locally and on the server. Will probably be information like you would store for a messaging app - user info, contacts, messages etc.

Anyone know which would be best to use? - or if another would suit my needs more?

Answer 1

The phonegap is a framework that allows you to create mobile applications using API's multi-platform web. The choice of the database in my view should not be given by the framework, but for what kind of application you are doing.

I see three ways to store data from your mobile application.

1: Local Storage (http://www.w3schools.com/html/html5_webstorage.asp)

2: SQLite (https://github.com/brodysoft/Cordova-SQLitePlugin)

3: Database on server (can be anyone.)

The choice will depend on what you want from your application. If it is a simple application that will be stored few data, use the local storage of html5 that stores documents. If your application is already a bit bigger and more complex, you can use SQLite implemented in the browser using HTML5 which is supported by most current mobiles browser. The advantage here is that access to the base is done without the need to build a server. In the third case your application would be the type client server, in which case you should use the database on the server. The choice of database can be what you feel is appropriate.

Answer 2

PhoneGap can use LocalStorage, SessionStorage, or SQLite databases. You can also use PhoneGap to connect to the devices native classes via a plugin, and pass the native class data, that it will then store on the device. check this link to find more details What database does PhoneGap use and what is the size limit?

Answer 3

I suggest you go with IndexedDB if you want to store a lot of data in the client or LocalStorage which is able to store 5MB worth JSON data.
This is just the front end but for the back-end there are so many to choose from and if you plan to write the back-end with Node then it will be wise to use MongoDB.

Answer 4

I would suggest using the Cordova-SQLitePlugin as it offers a native interface to sqlite, avoiding quota restrictions associated with WebSQL on mobile devices. The plugin is supported on Android, iOS and Windows Phone 8 platforms.

If you want to keep a local and remote database in sync, you may consider using this in conjunction with PouchDB