Question

I am storing my data structure values in SharedPreferences in onPause() methode of activity The SP.xml file size becomes 25K , will there be any effect of doing this storing in onPause() method if yes then What should I do to Store may datastructure in SharedPreferences .

Was it helpful?

Solution

25k is not extremely large but I still wouldn't recommend it. Depending on the needs and complexity of your app, you could look into an SQLite database or serialize your data and put it in an internal file.

OTHER TIPS

Storing in SharedPreferences lets you access your data virtually everywhere in the same application. Unless you need that data like a token or anything else small but significant you shouldn't do that (bad practice since it makes your application heavy) . It would be better to pass the information in a bundle if you are switching activities or fragment or save it in OnPause() to have the data when the application is resumed or OnSaveInstance() for rotation.

But unless its too much of structured Data, I would prefer SQLite. Throwing 100 select queries feels odd !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top