0

Now I use encrypted sharedpreferences. Sometimes the application can not load or save data and too often crashes randomly during the encryption / decryption process: ( That is why I am looking for a better way to store data. I need to have immediate access to stored data from multiple load / saves.

Is SQLite Database better choice? Is SQLite more stable than sharedpreferences?

user2742762
  • 401
  • 4
  • 5
  • Sqllite will more better if data is large. And you can easily perform operation like search,orderby,groupby faster way. – Biraj Zalavadia Sep 10 '13 at 09:15
  • Note that the SQLite in Android does not by default have any encryption support. So it is up to you to handle the ciphering. – Kung Foo Sep 10 '13 at 09:17

1 Answers1

3

It totally depend on your data, which you want to store.

SharedPreferences

 1) Small data.
 2) Unstructured.
 3) Like login info, user prefs, etc.

SharedPreferences is a key/value store where you can save a data under certain key. To read the data from the store you have to know the key of the data. This makes reading the data very easy. But as easy as it is to store a small amount of data as difficult it is to store and read large structured data as you need to define key for every single data, furthermore you cannot really search within the data except you have a certain concept for naming the keys.

SQLite

 1) Large data.
 2) Structured.
 3) Organized.

Large amounts of same structured data should be stored in a SQLite database as databases are designed for this kind of data. As the data is structured and managed by the database, it can be queried to get a sub set of the data which matches certain criteria using a query language like SQL. This makes it possible to search in the data. Of course managing and searching large sets of data influences the performance so reading data from a database can be slower than reading data from SharedPreferences.

GoRoS
  • 5,183
  • 2
  • 43
  • 66