Answers for "android room create or update"

0

android room create or update

@Dao
interface PinDao {

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insertIgnore(entity: Pin) : Long

    @Update
    fun update(entity: Pin)

    @Transaction
    fun insertOrUpdate(entity: Pin) {
        if (insertIgnore(entity) == -1L) {
            update(entity)
        }
    }
}
Posted by: Guest on August-16-2021

Browse Popular Code Answers by Language