Cordova-sqlite-storage: What's the difference to using localStorage?

Created on 12 Nov 2016  路  3Comments  路  Source: storesafe/cordova-sqlite-storage

I am wondering what are the differences between using a sqllite database and using localStorage? Both seem to be backed up by iCloud and both can store key / value pairs, so what's the major advantage from using the one above the other?

question doc-todo

Most helpful comment

Good points by @brodybits , but there is more:

  • Under iOS LocalStorage content might be dropped by the OS if memory gets low. (http://gonehybrid.com/dont-assume-localstorage-will-always-work-in-your-hybrid-app/)

This seems to be the case with an app a customer recently published, though I don't have exact proof.

There are also drawbacks of SQlite storages and such:

  • LocalStorage access is synchronous while SQLite and similar are asynchronous. This results in much more application logic required to use those solutions.

All 3 comments

Here are a few benefits I can think of:

  • no arbitrary limits (the browser generally has a limit such as 5 MB or 50 MB)
  • flexible database schema with multiple tables, indexing, and table joins
  • It would be possible to replace Cordova with a native framework and continue to use the same sqlite database.

Good points by @brodybits , but there is more:

  • Under iOS LocalStorage content might be dropped by the OS if memory gets low. (http://gonehybrid.com/dont-assume-localstorage-will-always-work-in-your-hybrid-app/)

This seems to be the case with an app a customer recently published, though I don't have exact proof.

There are also drawbacks of SQlite storages and such:

  • LocalStorage access is synchronous while SQLite and similar are asynchronous. This results in much more application logic required to use those solutions.
  • Under iOS LocalStorage content might be dropped by the OS if memory gets low. (http://gonehybrid.com/dont-assume-localstorage-will-always-work-in-your-hybrid-app/)

Nice link, I will add it to README.md when I get a chance.

  • LocalStorage access is synchronous while SQLite and similar are asynchronous. This results in much more application logic required to use those solutions.

That is definitely true. I recently published brodybits / sql-promise-helper to make some SQL operations easier for a customer and will add more if there is interest from the community.

Was this page helpful?
0 / 5 - 0 ratings