Skip to content

Instantly share code, notes, and snippets.

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();
public String convertObject(Pet pet) {
return gson.toJson(pet);
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