Skip to content Skip to sidebar Skip to footer

Room Typeconverter Not Working

I have an issue with Room not recognizing my converter. Error: Cannot figure out how to save this field into database. You can consider adding a type converter for it. I need t

Solution 1:

Room does not like generics much. I had to do this:

@TypeConverter
public static String toString1(Map<String, String> m){
    ...
}

@TypeConverter
public static String toString2(Map<Integer, String> m){
    ...
}

@TypeConverter
public static String toString3(Set<Integer> s){
    ...
}

@TypeConverter
public static String toString4(List<Integer> l){
    ...
}

not just

@TypeConverter
public static String toString(Map m){
    ...
}

@TypeConverter
public static String toString(Collection<Integer> c){
    ...
}

Post a Comment for "Room Typeconverter Not Working"