I am creating an Entity (Room Persistence Library) class Food, where I want to make foodId
as autoincrement.
@Entity
class Food(var foodName: String, var foodDesc: String, var protein: Double, var carbs: Double, var fat: Double)
{
@PrimaryKey
var foodId: Int = 0
var calories: Double = 0.toDouble()
}
How can I set foodId
an autoincrement field?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…