Room error: Not sure how to handle insert method's return type
AlarmEntity...alarms
this translates in multiple inserts. So the return type should be a List<Long>
or a long[]
, and it makes sense. If you pass two items you will get two id, one for each newly inserted row.
If you want to insert only 1 item at time, remove the varargs
(...
). EG
@Insert
long insert(AlarmEntity alarms);
From Accessing data using Room DAOs:
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.
Change the return type of insertAll ()
to long[] or List
Following the documentaion 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<Long>
instead.
in your case you have a list as paramater, you should return long[]
or List<Long>
Source : https://developer.android.com/training/data-storage/room/accessing-data#java