【发布时间】:2020-10-25 08:09:23
【问题描述】:
当我想将我的 JSON 记录到 Room 数据库时遇到问题。
我的数据类是:
data class CurrentWeatherEntry(
@SerializedName("temperature")//
val temperature: Int,
@SerializedName("weather_code")
val weatherCode: Int,
@SerializedName("weather_icons")
val weatherIcons: List<String>,
)
{
@PrimaryKey(autoGenerate = false)
var id : Int = CURRENT_WEATHER_ID
}
I get error: Cannot figure out how to save this field into database. You can consider adding a type
converter for it.
private final java.util.List<java.lang.String> weatherIcons = null;
How to create converter?
【问题讨论】:
-
这能回答你的问题吗? Room TypeConverter