I need to type converter for calendar type to add room database.
error:
Cannot figure out how to save this field into database. You can consider adding a type converter for it.
I need to type converter for calendar type to add room database.
error:
Cannot figure out how to save this field into database. You can consider adding a type converter for it.
While using Room DB for complex data you should write custom type converters. Please find an example for a Date converter (This will convert date to a Long value and back):
public class DateTypeConverter {
@TypeConverter
public static Date toDate(Long value) {
return value == null ? null : new Date(value);
}
@TypeConverter
public static Long toLong(Date value) {
return value == null ? null : value.getTime();
}
}
Also, you can refer to this answer.