phonegap - sqlite or Indexed DB?
Asked Answered
W

5

18

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.

Woodcutter answered 31/1, 2013 at 11:18 Comment(0)
S
12

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

Slapdash answered 31/1, 2013 at 11:57 Comment(3)
I've seen this example, but I am not convinced to that solution. What with this Cordova-WP-SqlitePlugin? Does it work?Ida
I've never tried Cordova-WP-SqlitePlugin so don't have any info how stable/good it is.Slapdash
Using Cordova-WP-SqlitePlugin, it's not very stable. Whole bunch of errors, always shows SQLite as busy. Not recommended.Roundfaced
T
3

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.

Trademark answered 18/6, 2014 at 13:26 Comment(0)
L
3

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

Liatrice answered 14/9, 2014 at 1:53 Comment(4)
First, both indexedDB and WebSQL have official web pages, as part of the w3c standards effort. SQLite is not an open standard. Second, it is your opinion that developers actively avoid indexedDB. My experience is different. Third, there is not a plugin called "Polyfill" -- in web development, a "polyfill" is a library that looks at what is implemented in the current browser, and supplies re-implementations for what's missing. Yes, there exists a decent polyfill for indexedDB (check github) which makes the API available everywhere.Extravagant
@JonWatte Which is fine. There is no such thing as a perfect solution for all situations. Arguing over Internet is like trying to be the best in Special Olympics. You can tell me more, for me and anyone else who will be choosing a storage techonlogy. What is the advantages of using IndexedDB over WebSQL or SQLite?Liatrice
By the way, the first result after typing in "polyfill" on Google says it is a plugin, and the Wikipedia entry on Polypill defines it as "is downloadable code which provides facilities that are not built into a web browser" which is exactly what a plugin in is, and what a plugin typically does. Maybe it is installed differently compared to other common plugins, but that is exactly what a plugin does.Liatrice
The original poster says that there exists "a" plugin that is called "Polyfill." "Polyfill" is not the name of "a" plugin -- there are many plugins (and libraries) that provide polyfill functionality. Saying that you need "another plugin called Polyfill" is like saying you need "another thread" when what you're looking for "a blue Men's shirt."Extravagant
C
3

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 ;)

Cantabile answered 8/5, 2015 at 22:27 Comment(1)
localForage is maintained by Mozilla, which is a huge plus. However, they have a few edge cases left to be covered, and at the same time that the API is the simpler, it's also the most poor.Culpable
O
1

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

Edit:

Oakum answered 14/8, 2013 at 10:30 Comment(1)
Um, care to make it easy for us and give a link?Plainsong

© 2022 - 2024 — McMap. All rights reserved.