I have an ArrayList of Persons (ArrayList<Person>), I want to store that ArrayList in a persistent data type. SharedPreferences are a solution BUT it’s just manipulating String, int, float`… variables. Do you have some ideas?
Thank you very much.
I have an ArrayList of Persons (ArrayList<Person>) , I want to store that ArrayList
Share
Much simpler is to use java
Serialisation.You just need an Persons class:
Then simply use
read back with
The disadvantage is when battery power is lost during writing. Some people write to a temporary file first, delete the old and rename to the correct file name.
For high performance (much less space, much faster)
You could use
DataOutputStream, but then you have to write all fields yourself (but this is simple too)