开发者

Best way to store data in Android [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t开发者_如何转开发 allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 2 years ago.

Improve this question

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 applications.

  1. SQLiteDatabase
  2. ContentProvider
  3. SharedPreference
  4. or File storage
  5. 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.


I recently discovered db4o [http://www.db4o.com/android/]. It's not the best choice to store logs but if you want to store the data in your object this is certainly an excellent alternative to SQLite.


You can also keep the data inside the XML file created by your application. In many applications I have done so .And using any SAX or DOM parser you can retrieve data smoothly. No other application can access that XML.

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜