Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

local storage vs database(SQLite) for a cordova app

I am developing a mobile app using javascript and cordova framework. My requirement is that a user enters something in the input textbox. This needs to be stored so that the user need not enter the same text again. It should be already present as a list or something. I went though a lot of documentation. Could someone tell me what is the difference in the local storage (HTML5 storage Apis) and SQL Lite database. And which one should I use for this use case?

Thanks

like image 243
Ankur Bhatia Avatar asked Aug 09 '15 08:08

Ankur Bhatia


2 Answers

Local storage using the HTML5 storage APIs stores your data in its own directory. It will not be backed up reliably, if at all. It is also subject to the limits imposed by the browser.

A sqlite database, if created using https://github.com/litehelpers/Cordova-sqlite-storage, is stored in a location that is known and will be backed up. (It is possible to store the sqlite database in a location that is NOT backed up by iCloud.) This plugin provides the same Javascript API for iOS, Android, Windows Phone 8, and Windows "Universal" (Windows 8, Windows 8.1, and Windows Phone 8.1).

DISCLAIMER May 2016: I am the primary owner and maintainer of Cordova-sqlite-storage.

like image 169
brodybits Avatar answered Oct 06 '22 01:10

brodybits


Local storage is a DOM-standard key-value permanent storage until the user throws away the history, and it has a size limit from 5 to 10MB. Since you're using Cordova, there's no history to throw away, but if the app were hosted as standard Web browser app, the history comes to play as I mentioned above.

A SQLite database is a full regular relational embedded storage and it can be a good friend if you want to cache/store large amounts of data on the client-side and you need to query it by complex criterias.

like image 30
Matías Fidemraizer Avatar answered Oct 06 '22 01:10

Matías Fidemraizer