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

前端 未结 7 1233
野性不改
野性不改 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<Long> for multiple insert operations
    • void if you don't care about the inserted id(s)
    0 讨论(0)
提交回复
热议问题