1 year ago

#74761

test-img

Fábio Pires

How to return the ID of the inserted row in Room database

I am inserting some rows in my Room database but I want to be able to access the ID of the inserted row.

How can I do it?

repo.insertMedication(new Medication(name, quant_aux, time));

Repository insertMedicationMethod

  public void insertMedication(Medication medication){
        new InsertAsyncTask(medicationDB.getMedicationDao()).execute(medication);
    }

DAO

 @Insert
    long[] insertMedication(Medication... medication);

android

insert

android-room

dao

0 Answers

Your Answer

Accepted video resources