Store objects in Android -


I would like to know what would be the best option to store custom Java objects in my application. I read about the serialization But it is quite slow.

What is the best option?

If you are not collecting more data then you can replace the java object in the JSON string and You can use GSN to store the string in your app preferences. There is a TOGSON (OBJ) method and visa in GSN.

Obtaining data from app preferences and in an object:

  String Jason = AppSharePrince. String ("some name" ""); Return gson.from Jason (json, YourModel.class);   

To get data from your object in app preferences:

  string json = gson.toJson (obj);   

then prefsEditor.putString ("someName", json) .apply () .

Comments