Skip to content Skip to sidebar Skip to footer

How To Apply Room TypeConverter To A Single Field Of An Entity?

I have been trying different solutions for applying a TypeConverter to a single field of a Room database entity but I am getting an error Cannot figure out how to save this field

Solution 1:

You must specify that the annotation should be applied to the field

@field:TypeConverters(DateStringConverter::class)
val date: Date

If you don't specify a use-site target, the target is chosen according to the @Target annotation of the annotation being used. If there are multiple applicable targets, the first applicable target from the following list is used:

  • param (constructor parameter);
  • property;
  • field.

https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets


Post a Comment for "How To Apply Room TypeConverter To A Single Field Of An Entity?"