存储在Android的数据的最佳方式 [英] Best way to store data in android
问题描述
我要存储的结构形式,即数据对多呼叫(如呼叫日志)的所有信息。我应该怎么preFER?而我不希望与其他应用程序共享数据。
- SQLiteDatabase
- 的ContentProvider
- 共享preference
- 或文件存储
- 或任何方式对我的要求,我不知道。
共享preferences
显然在内部实现为一个XML文件,该文件是序列化和反序列化的全在更新。而且它没有索引键值存储。因此,使用与您的应用程序相关的只有简单的数据。任何超过50个按键和你可能已经过头了。
的ContentProvider
是用于在应用程序之间共享数据。你已经明确表示你不想这样做。
SQLiteDatabase
适用于各个应用程序来存储数据,并提供了很大的灵活性,存储和索引数据的方式不同。我个人用它来存储日志在我的应用程序之一。我建议这条路线。
另一种选择是登录到存储在文件存储普通文本文件。
I want to store data in structure form i.e. all information about many call (like call logs). What should i prefer ? and i don't want to share my data with other application.
- SQLiteDatabase
- ContentProvider
- SharedPreference
- or File storage
- or any way for my requirement which i don't know.
SharedPreferences
is apparently implemented internally as an XML file which is serialized and deserialized in full on update. And it's a Key-Value store with no index. So use that only for simple data associated with your app. Any more than 50 keys and you've probably overdone it.
ContentProvider
is intended for sharing data across applications. You've explicitly said you don't want to do that.
SQLiteDatabase
is intended for individual apps to store data, and provides a lot of flexibility to store and index data in different ways. I personally use it to store logs in one of my apps. I'd recommend that route.
Another option is to log into ordinary text files stored in file storage.
这篇关于存储在Android的数据的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!