优点和SQLite的缺点和共享preferences [英] Pros and Cons of SQLite and Shared Preferences

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

问题描述

什么是存储之间的SQLite数据库和共享preferences信息的良好机制?

what is the good mechanism to store information among SQLite database and Shared Preferences ?

为什么我们使用的共享preference?为什么使用SQLite?这些问题让我困惑?我试过很多找到它们之间的区别?并存储数据的更好的机制?但我am't能够找到谷歌相应的答案。请帮我..with最好的例子和解释。

Why we use shared preference ? Why we use sqlite ? these questions made me confusing ? i tried much to find difference among them ? and better mechanism for data storing ? but i am't able to find the appropriate answer on google. Please help me ..with best examples and explanation.

推荐答案

这真的取决于你要存储的数据。

It really depends on the data you want to store.

的SQLite

大量的相同结构化数据应该存储在SQLite数据库如数据库被设计用于此类型的数据。作为数据的结构,并由数据库管理的,它可以被查询以获得一个子集相匹配使用像SQL查询语言特定标准的数据。这使得能够在数据中搜索。当然,管理和检索大量数据的影响表现所以从数据库中读取的数据可以比从共享preferences读取数据慢。

Large amounts of same structured data should be stored in a SQLite database as databases are designed for this kind of data. As the data is structured and managed by the database, it can be queried to get a sub set of the data which matches certain criteria using a query language like SQL. This makes it possible to search in the data. Of course managing and searching large sets of data influences the performance so reading data from a database can be slower than reading data from SharedPreferences.

共享preferences

共享preferences是键/值存储在那里,你可以节省下一些关键数据。若要从存储器中读取的数据,你必须知道数据的关键。这使得读取数据非常容易。但由于容易,因为它是存储数据量小的困难是储存,当你需要定义键,每一个数据读取大量的结构化数据,而且你不能真正的数据中进行搜索,除非你有一定的概念命名的键。

SharedPreferences is a key/value store where you can save a data under certain key. To read the data from the store you have to know the key of the data. This makes reading the data very easy. But as easy as it is to store a small amount of data as difficult it is to store and read large structured data as you need to define key for every single data, furthermore you cannot really search within the data except you have a certain concept for naming the keys.

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

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