Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class PetConverter extends PreferenceTypeConverter<Pet> {
private final Gson gson;
/**
* default constructor will be called by PreferenceRoom
*/
public PetConverter() {
this.gson = new Gson();
}
@Override
public String convertObject(Pet pet) {
return gson.toJson(pet);
}
@Override
public Pet convertType(String string) {
return gson.fromJson(string, Pet.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment