简体   繁体   English

用于cordova应用程序的本地存储与数据库(SQLite)

[英]local storage vs database(SQLite) for a cordova app

I am developing a mobile app using javascript and cordova framework. 我正在使用javascript和cordova框架开发移动应用程序。 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. 有人能告诉我本地存储(HTML5存储Apis)和SQL Lite数据库有什么区别。 And which one should I use for this use case? 我应该将哪一个用于此用例?

Thanks 谢谢

Local storage using the HTML5 storage APIs stores your data in its own directory. 使用HTML5存储API的本地存储将您的数据存储在其自己的目录中。 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. 如果使用https://github.com/litehelpers/Cordova-sqlite-storage创建的sqlite数据库存储在已知且将要备份的位置。 (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). (可以将sqlite数据库存储在不由iCloud备份的位置。)此插件为iOS,Android,Windows Phone 8和Windows“Universal”提供相同的Javascript API(Windows 8,Windows 8.1和Windows Phone 8.1)。

DISCLAIMER May 2016: I am the primary owner and maintainer of Cordova-sqlite-storage. 免责声明2016年5月:我是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. 本地存储是DOM标准键值永久存储,直到用户丢弃历史记录,并且其大小限制为5到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. 由于您使用的是Cordova ,因此无法丢弃历史记录,但如果应用程序作为标准Web浏览器应用程序托管,则会像上面提到的那样发挥历史。

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. SQLite数据库是一个完整的常规关系嵌入式存储,如果您想在客户端缓存/存储大量数据,并且需要通过复杂的标准进行查询,它可以成为一个好朋友。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM