val db: AppDatabase = Room.databaseBuilder(app, AppDatabase::class.java, "MyDb.db") .build()db.runInTransaction { item.updateImage(imageDataSource) dataSource.update(item)}
or
interface BaseDao<T> { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(entity: T) : Long @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertAll(vararg entity: T) @Update fun update(entity: T) @Update fun updateAll(vararg entity: T) @Delete fun delete(entity: T)}@Daointerface PinDao : BaseDao<Pin> { @Transaction public void replacePin(newPin: Pin, oldPin: Pin) { insert(newPin) delete(oldPin) }}