I have a room table called scores_table
. I only want to store the last 100. How can I do this using Room?
@Entity(
tableName = "score_table",
indices = [
Index(value = ["id"])
]
)
data class ScoreEntity(
@PrimaryKey
@ColumnInfo(name = "id")
var id: Long = 0
@ColumnInfo(name = "creation_time")
var creationTime: Long = System.currentTimeMillis()
...
)
To insert I use this:
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(entity: ScoreEntity)