开发者

Shared Preferences vs Database

My data is simple property values so I could store either way, but I was wondering which is more reliable? Are shared preferences auto saved and therefore more reliable? Or because they are non-transactional is that开发者_JAVA百科 less reliable?


The use of SharedPreferences or a ContentProvider/SQLite database is situation-based. In your situation, I would recommend using SharedPreferences. A SQLite database is meant for potential hundreds of entries. SQLite database can also be queried and the data retrieval is much more robust. The SQLite database adds immense power to your entries. But in your case, I would recommend using SharedPreferences, unless you have the unusual need to sort/filter through your property values. They are both reliable services, SharedPreferences are not autosaved, you must use commit() to save changes. The SQLite database is a lot more structured than SharedPreferences. For more information check out docs.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜