As someone who recently discovered the beauty of the simplicity of NoSQL document storage (namley CouchDB), I am very tempted when you need to constantly store simple objects or small arrays to use the Json serializer to store this data as a JSON string in general preferences. The benefits that I see:
- There is no additional complexity, because (in my project) I already have a JSON Framework for my REST API, which easily converts JSON / Objects
- I would also argue: less complexity, since I can just use POJO and not have to take care of the keys / values ββmanually
- Unlike Java serialization or androids, this is a more or less universal format that is easy to understand even for people and easily parses all the various platforms.
- When properly equipped, it is easy to handle the update case in which the data model changes, and the configuration must be transferred (ignore the unkown properties and set new default values ββin Jackson, for example.)
- Again, with the right tools, serialization can be performed on a single line of code:
mapper.writeValueAsString(myObject);
The disadvantages that I see are:
- Slowly if you use the convenient serial input method (data binding in Jackson, for example), but I'm not sure if this plays any role if you use "save config"
- It takes a little more space - again, I think it's insignificant
, ( SharedPreferences , ), , "config config" / .
/ , .