I am writing an Android app for a co-worker that keeps track of Kids signed up for a soccer league. I am currently having trouble saving/serializing my roster then deserializing it later. The object I am serializing is an array of Player objects. The custom player class implements serializable so an array of them should be fine to serialize (as far as I know).
My serialization/saving method:
String ser = SerializeObject.objectToString(currentRoster.getRosterArray());
if (ser != null && !ser.equalsIgnoreCase("")) {
SerializeObject.WriteSettings(this, ser, "playerRoster"); //.dat extension
} else {
System.out.println("Object not saved");
SerializeObject.WriteSettings(this, "", "playerRoster");
}
My deserialization method:
String ser = SerializeObject.ReadSettings(this, "playerRoster");
if (ser != null && !ser.equalsIgnoreCase("")) {
Object obj = SerializeObject.stringToObject(ser);
// Then cast it to your object and
if (obj instanceof Player[]) {
// Do something
loadedRoster = (Player[]) obj;
System.out.println(loadedRoster[0]);
}
}
The result I am getting in my app is jargon for every player in the array when deserialized. My question is on if I am correctly saving and loading the data, or am I forgetting something. (I left out some of the filler code and exception handling to keep it cleaner) Thanks for any help!