This is how I am inserting data into database using Room Persistence Library:
Entity:
@Entity
class User {
@PrimaryKey(autoGenerate = true)
p
According to the documentation functions annoted with @Insert can return the rowId.
If the @Insert method receives only 1 parameter, it can return a long, which is the new rowId for the inserted item. If the parameter is an array or a collection, it should return long[] or List
instead.
The problem I have with this is that it returns the rowId and not the id and I still haven't found out how to get the id using the rowId.
Sadly I can't comment yet, because I don't have 50 reputation, so I am posting this as an answer instead.
Edit: I now know how to get the id from the rowId. Here is the SQL command:
SELECT id FROM table_name WHERE rowid = :rowId