Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 less reliable?

like image 855
Androider Avatar asked Feb 14 '11 01:02

Androider


1 Answers

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.

like image 134
Mohit Deshpande Avatar answered Nov 03 '22 10:11

Mohit Deshpande