Shared Preferences vs Database

后端 未结 1 395
别跟我提以往
别跟我提以往 2020-12-31 02:52

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? O

相关标签:
1条回答
  • 2020-12-31 03:16

    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 讨论(0)
提交回复
热议问题