【发布时间】:2019-01-18 09:39:44
【问题描述】:
我需要编写类型转换器来将 ArrayList 保存为列。我试过写转换器,但没有结果,我得到这个错误:
“错误:不确定如何将 Cursor 转换为此方法的返回类型”
@Entity(tableName = "WeightRecords")
class WeightRecords : Serializable {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
@ColumnInfo(name = "weightRecords")
var weightRecords: Double = 0.0
@ColumnInfo(name = "days")
var days: String = ""
@ColumnInfo(name = "data")
var data: ArrayList<Float>? = ArrayList()
}
@Dao
abstract class WeightRecordDao : BaseDao<WeightRecords>() {
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun insertWeightRecords(weightRecords: WeightRecords): Long
@Query("SELECT data FROM WeightRecords")
abstract fun getData(): ArrayList<Float>
}
我需要写类型转换器,请帮忙!!
【问题讨论】:
标签: arraylist kotlin typeconverter