Check whether list of items inserted succesfully or not in room table


Dao :

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertProducts(dataUser: List<Products>)

i am inserting list of products in the table at a single time …i know whether the all data inserted successfully or not

i tried all the ways like return type of Long ( but it is working only for inserting single item )

Also please tell me the viewmodel code ..that how could i receive the success value or failure that i can process the next step easily


I think you were close. You are inserting multiple items. So it’s not going to be Long but List<Long>(or Array not sure right now if Room can convert it automatically) (doc).

Answered By – TheLibrarian

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published