Skip to content Skip to sidebar Skip to footer

Room Api - How To Retrieve Recently Inserted Generated Id Of The Entity?

I need to retrieve the generated id value of an entity which is recently inserted as the code sample added below demonstrates: As mentioned above, the id field of the entity Stude

Solution 1:

Have your @Insert method return a long:

@InsertlonginsertStudent(Student s);

The return value will be the rowId of the row, and that should be the auto-generated primary key value.

Post a Comment for "Room Api - How To Retrieve Recently Inserted Generated Id Of The Entity?"