I am creating an Entity (Room Persistence Library) class Food, where I want to make foodId as autoincrement.
foodId
@Entity class Food(var foodName: Str
Annotate your Entity class with the code below.
In Java:
@PrimaryKey(autoGenerate = true) private int id;
In Kotlin:
@PrimaryKey(autoGenerate = true) var id: Int
Room will then auto-generate and auto-increment the id field.