共享preference和SQLite差异 [英] Difference between shared preference and sqlite

查看:139
本文介绍了共享preference和SQLite差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个话题已经被讨论过的计算器。但是,仍然有一些事情是不明确的,当我读到它previous职位。所以在这里,他们是:

I know this topic has been discussed before on stackoverflow. But there are still some things that are not clear when i read previous posts about it. So here they are:

  • 我知道,我们使用的共享preference小数据和SQLite,大数据处理。
  • 因此,如果我们只是想保存的用户名和密码,我们应该使用共享preferences?
  • 在惯于共享preferences被当用户卸载应用程序失去了什么?比如我下载名为ABC的一个应用程序,并保存用户名和密码。然后,我从一个电话中卸载这个程序,并尝试使用相同的用户名和密码,其他电话访问。这是否会使用共享prefernces或数据被保存会丢失?
  • 什么是我们使用了另一种旁边大大小小的数据的主要原因是什么?

推荐答案

可以认为,在数据大小方面的共享preferences和SQLite数据库之间的差异,但不是完全准确。一个更好的办法来把它在数据结构方面要存储。

You can think of the difference between shared preferences and an SQLite database in terms of data size but that isn't entirely accurate. A better way to think of it is in terms of the structure of the data you want to store.

共享preferences只能存储键值配对而SQLite数据库是灵活得多。因此,共享preferences是用于存储用户preferences,如特别有用应在应用程序中显示通知等虽然SQLite数据库是公正的东西是有用的。

Shared preferences can only store key-value pairings whilst an SQLite database is much more flexible. So shared preferences are particularly useful for storing user preferences, e.g. should the app display notifications etc. Whilst an SQLite database is useful for just about anything.

这两个数据源是本地,但你应该知道的是能够备份你的应用程序数据,云存储链接到用户的谷歌账户。这使得它更容易为你的用户更改设备,并为他们的应用能够轻松转移到新的设备。欲了解更多信息看看这里

Both data sources are local but something you should be aware of is the ability to backup your application data to cloud storage that is linked to the user's Google account. This makes it much easier for your users to change devices and for their applications to easily transfer to the new device. For more info take a look here.

这篇关于共享preference和SQLite差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆