Im using @RawQuery to execute my query in Room Database. But i cant find a way to get the affected rows this way.
I tried SELECT changes() as affected_rows
and get the result through the cursor but it always return zero.
My code so far (I run this code after my insert, update, delete statements).
val cursor = daoUnit.query(SimpleSQLiteQuery("SELECT CHANGES() AS affected_rows"))
var affectedRowCount = 0
cursor.use { innerCursor ->
val affectedRowColumn = innerCursor.getColumnIndex("affected_rows")
if (innerCursor.count > 0 && innerCursor.moveToFirst()){
affectedRowCount = innerCursor.getInt(affectedRowColumn)
Log.e("TAG", "AFFECTED ROW COUNT : $affectedRowCount")
}
}