Android Room - Get the id of new inserted row with auto-generate

前端 未结 7 1309
野性不改
野性不改 2020-11-29 00:03

This is how I am inserting data into database using Room Persistence Library:

Entity:

@Entity
class User {
    @PrimaryKey(autoGenerate = true)
    p         


        
7条回答
  •  孤独总比滥情好
    2020-11-29 00:48

    Based on the documentation here (below the code snippet)

    A method annotated with the @Insert annotation can return:

    • long for single insert operation
    • long[] or Long[] or List for multiple insert operations
    • void if you don't care about the inserted id(s)

提交回复
热议问题