Phonegap: WebSql or SqLite?
Asked Answered
W

3

13

I have been working with phonegap for little time, and i'm having some trouble with the concept of storage in it.

So, the documentation states that there is this database that you can open, and it is a SQLite implementation."window.openDatabase returns a new Database object.

This method will create a new SQL Lite Database and return a Database object. Use the Database Object to manipulate the data." http://docs.phonegap.com/en/2.2.0/cordova_storage_storage.md.html#Database I'm using it at my webApp right now:

var myBuggedDb = window.openDatabase(shortName, version, displayName,maxSize);

It works like a charm. I can use it to make queries, from selects to delete's. All good, right? But when i inspect and debug my code, i see that what is created is a WebSql database. I have also consulted a lot of blogs, wiki's and other places to get more info about the topic. It seens a lot of people make a mess out of both techs. Phonegap Plugin page doesn't even have the sqlite plugin.

And now, we are going to change our app so it takes from a localStorage a JSON object and converts it. I want to insert it into our database. But now i'm confused, i don't know if this is webSql or SQLite. Could someone clarify? Will it work as a SQLite or as a WebSql after all, on the device?

EDIT: If you are looking for this question in the future, tread carefully: The technologies have changed a lot, indexedDB support is growing, there are many other options as well, like Lawchair and such. Do a little research before using anything!

Wixted answered 21/11, 2013 at 13:1 Comment(0)
B
7

HTML 5 has this implementation of databases and the implementation is done by embedding Sql Lite database in to browser.

Browser's like chrome and Safari have there implementation of Html5 databases implemented using sqlLite termed as websql but when I was in touch, Mozilla wasn't implementing the Websql instead they were implementing Indexed DB.

Better option I think is to use Backbone.js or Lawnchair although internally both of them use websql but the API's wrap everything for you.

Hope this helps.

Bibliomancy answered 21/11, 2013 at 13:18 Comment(1)
Yes, this helped a lot to clarify. IndexedDB right now to us is not a option because of mobile compatibility. But i'm checking out Lawnchair. Thanks, Varun!Wixted
Z
7

I would suggest to go with WebSQL. The detailed reason is as mentioned below:

Lets go ahead and consider the 3 major platforms that you will go with using PhoneGap:

  • IOS: WebSQL - SUPPORTED SQLite - PARTIALLY SUPPORTED
  • Android: WebSQL - SUPPORTED SQLite - FULLY SUPPORTED
  • Windows: WebSQL - NOT SUPPORTED SQLite - NOT SUPPORTED

So ideally it goes like this - You have Windows over which you wrap up a WebSQL Plugin [unreliable] above which you wrap up a SQLite Plugin [highly unreliable].

Hence - It's now your call. Even if you are making phonegap Apps they are mean to be fast and creating layers of one stack over another will definitely make it slow.

Zaidazailer answered 25/5, 2015 at 11:4 Comment(1)
WebSQL is deprecated. programmers.stackexchange.com/questions/220254/…Lattimer
U
1

var myBuggedDb = window.openDatabase(shortName, version, displayName,maxSize); opens websql database. If you want to use Sqlite, you must use 3rd party plugins like https://github.com/litehelpers/Cordova-sqlite-storage

Unaccountable answered 8/9, 2015 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.