Ad

Is It Okay To Use Shared Preferences For Big Data Objects?

- 1 answer

I know there are some topics and posts about this question, but i want to have an individual feedback. So in my app i use one shared preferences (file) and gson to store a list of objects, containing big amount of data. So my shared preference file is about 5 MB big and contains ca 1 Mio characters. I know this sounds not really good, but my app works perfectly. No long loading or saving times.

I choose this method, because i ONLY want to store the data, when my app will be closed and between app starts.

I know really good, that shared prefs is not a good way and actually meant for saving small strings for preferences. So do i have to change this method or is it "okay"? Or does someone know a good solution, which is easy to use and understand, because for me sqlite is difficult and hard to use. Or is there a easy way to store an object into sql? (Maybe a library or a method??)

Thank you in advanced!

Ad

Answer

Rule of thumb: As long as it works does not necessarily mean it's good. Said that, SQLite is a perfectly valid solution for android applications. There is also a handy developer guide on how to save data with SQLite, but the recommended approach is actually to use the Room Persistence Library.

Ad
source: stackoverflow.com
Ad