最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - local storage vs database(SQLite) for a cordova app - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question asked Aug 9, 2015 at 8:59 Ankur BhatiaAnkur Bhatia 1,1385 gold badges18 silver badges31 bronze badges 2
  • BTW, I've answered you but I still think that I can't give credit to that you said "I went through a lot of documentation" and you weren't able to find out the differences... ;) – Matías Fidemraizer Commented Aug 9, 2015 at 9:18
  • @Matias-Thanks a lot for answer. Actually I did go through documentations. What I didn't get was the difference in the context of my requirement. – Ankur Bhatia Commented Aug 10, 2015 at 10:09
Add a comment  | 

2 Answers 2

Reset to default 16

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.

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.

发布评论

评论列表(0)

  1. 暂无评论