I have an array of objects in my Android app which I would like to store persistently. The options I’m aware of are:
- Store in a db — sqlite
- Store in a file — like in XML
- Store in SharedPreferences
I really want the simplest and cleanest implementation. Is #3 even feasible? I haven’t found any discussion of that, although that is the solution I used on my iPhone version of the app.
In Java, the trick is to implement the interface Serializable. As long as the entire object graph you’re trying to serialize contains only objects that also implement Serializable, the default serialization algorithm can use reflection to generate the byte stream for you, and you can output it to anything that can accept a byte stream