title: Android Room error: TypeConverter not recognised for List of Enums
body: <p>The Room library is not recognizing a <code>TypeConverter</code> I created for a <code>List</code> of enums. However, when I change this to an <code>ArrayList</code> of enums it works fine. Anyone has any idea why and what can I do to make this work with <code>List</code>? (Using List in Kotlin is easier and I really don't wanna be converting back and forwards to <code>ArrayList</code> just because of this).</p>
  
  <p>Here is my code:</p>
  
  <p>My model:</p>
  
  <pre><code>@Entity
  data class Example(@PrimaryKey val id: String?,
                     val name: String,
                     var days: List&lt;DayOfWeek&gt;?)
  </code></pre>
  
  <p><code>DayOfWeek</code> is an enum:</p>
  
  <pre><code>enum class DayOfWeek {
  
      MONDAY,
      TUESDAY,
      WEDNESDAY,
      THURSDAY,
      FRIDAY,
      SATURDAY,
      SUNDAY;
  
      val value: Int
          get() = ordinal + 1
  
  
      companion object {
  
          private val ENUMS = DayOfWeek.values()
  
          fun of(dayOfWeek: Int): DayOfWeek {
              if (dayOfWeek &lt; 1 || dayOfWeek &gt; 7) {
                  throw RuntimeException("Invalid value for DayOfWeek: " + dayOfWeek)
              }
  
              return ENUMS[dayOfWeek - 1]
          }
  
      }
  
  }
  </code></pre>
  
  <p>My <code>TypeConverter</code>:</p>
  
  <pre><code>private const val SEPARATOR = ","
  
  class DayOfWeekConverter {
  
      @TypeConverter
      fun daysOfWeekToString(daysOfWeek: List&lt;DayOfWeek&gt;?): String? {
          return daysOfWeek?.map { it.value }?.joinToString(separator = SEPARATOR)
      }
  
      @TypeConverter
      fun stringToDaysOfWeek(daysOfWeek: String?): List&lt;DayOfWeek&gt;? {
          return daysOfWeek?.split(SEPARATOR)?.map { DayOfWeek.of(it.toInt()) }
      }
  
  }
  </code></pre>
  
  <p>And I set it in my DB class like this:</p>
  
  <pre><code>@Database(entities = arrayOf(Example::class), version = 1)
  @TypeConverters(DayOfWeekConverter::class)
  abstract class AppDatabase : RoomDatabase() {
  
      abstract fun exampleDao(): ExampleDao
  
  }
  </code></pre>
  
  <p>My DAO looks like this:</p>
  
  <pre><code>@Dao
  interface ExampleDao {
  
      @Query("SELECT * FROM example")
      fun getAll(): LiveData&lt;List&lt;Example&gt;&gt;
  
      @Insert(onConflict = REPLACE)
      fun save(examples: List&lt;Example&gt;)
  
  }
  </code></pre>
  
  <p>The error I get with this code is:</p>
  
  <pre><code>error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.
  e: 
  
  e:     private java.util.List&lt;? extends com.example.DayOfWeek&gt; days;
  </code></pre>
  
  <p>Like I said above, if I change the <code>days</code> property to <code>ArrayList&lt;DayOfWeek&gt;</code> (and make the changes to <code>ArrayList</code> in <code>DayOfWeekConverter</code>) then everything works fine. If anyone can help me figure this out and tell me how I can use <code>List</code> here it'd be of great help, it is driving me crazy :/.</p>