SQLite与LocalStorage

时间:2016-09-30 06:22:44

标签: sqlite local-storage ionic2

我正在使用Ionic 2。

我有一个简单的聊天应用程序,它使用Meteor在用户之间同步消息。在此阶段,所有消息都存储在Mongodb数据库中的服务器上。它运作得很好。

但是,我希望将消息存储在使用本地设备上,而不是从服务器下载,就像WhatsApp一样。

问题

我应该使用本地存储还是 SQLite

我倾向于本地存储,因为我保存的对象非常简单(只有keystring)。

本地存储 我打算用简单的JSON用密钥保存邮件。

SQLite的 我之前从未使用过这个,但是理解正常的SQL。

2 个答案:

答案 0 :(得分:2)

由于您的数据将是简单对象,因此建议您使用NoSQL DB而不是SQLite

在NoSQL数据库中,您可以将应用程序数据存储在文件中。您可以自由地按照您的结构存储对象,就像您的情况一样 - 键值对。即使在卸载应用程序后,应用程序数据也将保持不变,因为您可以将数据存储在设备的外部存储中

我建议请仔细阅读

http://developer.couchbase.com/documentation/mobile/1.1.0/develop/training/build-first-android-app/index.html

它是一个非常好的Android NoSQL DB库。

答案 1 :(得分:0)

The local storage store the data locally within the user's browser. And is very helpful for store small pieces of data. But remember, the browser has a limit to store data with local storage and depends which browser that you using.

Look at this link to might help you about the limits.

So, for your application the sqlite or nosql seems more suitable for your needs.