19
votes

I am web developer starting with phonegap. I need to create one app for iPhone, android and Windows Phone 8.
I need to store some data (too big for localStorage) locally.
I don't know witch solution is the best:

  1. Phonegap provides Storage (based on WebSQL - which is deprecated), but it is not supported by windows phone. Is there any plugin to fill this gap?
  2. I read about Indexed DB, but I haven't used it before and it is not very intuitive for me. I am not sure if it is fully supported in all platforms? I based on (http://blog.nparashuram.com/2012/10/indexeddb-example-on-cordova-phonegap_12.html)
  3. Or maybe I can use phonegap plugins https://github.com/marcucio/Cordova-WP-SqlitePlugin for windows phone and https://github.com/marcucio/Cordova-SQLitePlugin for android and iphone.. Then my code would be the same in all platforms as I suppose.

Did someone create such an app before? I would be greatful for any solutions or ideas.

5

5 Answers

12
votes

Cordova WP8 supports IndexedDB only. iOS and Android WebSql only. Since WebSql is deprecated (I know how many people love/use it and agree that in many situations WebSql is very cool) I would recommend to proceed with IndexedDb and use the following polyfill for Android/iOS.

PhoneGap polyfill for IndexedDB that makes the IndexedDB API to work with WebSQL

Example

3
votes

Latest Update (May 05, 2014): New Cross Platform Cordova WebSQL plugin by MS Open Tech

Microsoft Open Technologies is publishing the new open source WebSQL plugin for Apache Cordova and PhoneGap. This plugin allows developers to integrate a persistent SQL-based local storage solution in their Cordova apps using the exact same JavaScript code across Android, iOS, Windows Phone and Windows Store.

3
votes

IndexedDB -

  • It is incompatible with many types of popular mobile OS and versions
  • It is only compatible with very specific versions of mobile OS
  • Developers cannot use SQL with IndexedDB. SQL statements can be used on SQLite and WebSQL
  • Most developers actively avoid using IndexedDB as much as they can

WebSQL -

  • It has been deprecated by W3C which means it is no longer maintained or developed
  • It requires another plugin to enable mobile applications to work with popular mobile OS such as Google Android and Apple iOS

SQLite -

  • It received an award from Google
  • SQLite has its official website. IndexedDB and WebSQL do not
  • On Google, SQLite returns 1.8 million results. WebSQL returns a bit less than 700K results and IndexedDB returns 282K results.
  • Developer can use common SQL statements with SQLite
  • It is compatible with most versions of all popoular mobile OS such as iOS and Android

If you want a quick tutorial on SQLite

Storage of SQLite database using Android and Phonegap

3
votes

LocalForage seems to be the best and newest solution: https://github.com/localForage/localForage (1000 commits, 83 contributors)

It has fallbacks for none supported navigators. I haven't tried it yet (over phonegap) but as soon I do i'll give you feedback ;)

1
votes

How about using my open source library, ydn-db? It has very nice abstraction layer on top of those.

Edit: