我的数据类看起来像这样
@Entity(tableName = "items")
data class Item(
@ColumnInfo(name = "name") var name: String = "",
@ColumnInfo(name = "room") var room: String = "",
@ColumnInfo(name = "quantity") var quantity: String = "",
@ColumnInfo(name = "description") var description: String = "",
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id") var id: Long = 0
)
Room使用SQLite,而SQLite支持数据库中的NOT NULL列。我尝试使用@NonNull注释列,但并没有起作用。
有没有方法使Room数据库中的列不可为空?