Is it a good practice to have any number of shared preferences in an Android Application? Or we need to restrict it to a certain number? Will it impact the application performance?
Asked
Active
Viewed 442 times
1
-
If I recall (don't quote me), shared preferences are read in their entirety when you get the shared preferences object... a big XML file would be pretty slow to parse – Mgamerz Mar 04 '14 at 06:32
1 Answers
1
Depends upon how many preferences you are going to store. I prefer sqlite when need readability, its easy to read data in columns, whereas shared preferences are in xml file.
You can look at code it might help to decide.
Also it depends on your logic how frequent you commit changes, when you read you are reading from Map so will be in memory and faster but memory is limited.
I tested committing 1000 different elements read/write in sqlite and shared preferences and surprisingly shared preferences was 10 times faster than sqlite! though I had cache while reading sqlite. So I would say performance test you have to do with your own requirements.

Prakash
- 4,479
- 30
- 42