I am listening for changes in my local database with
@Query("SELECT * FROM favorite_recipes_table ORDER BY id ASC")
fun readFavoriteRecipesAsFlow(): Flow<List<FavoriteEntity>>
But when I run another method in my DAO to delete items in the same table:
@RawQuery
suspend fun deleteFavoritesRecipe(query: SupportSQLiteQuery): Int
The flow returned from readFavoriteRecipesAsFlow is not called. What could be the problem?
This happens because
@RawQuerywas used.According to this issue: https://issuetracker.google.com/issues/235373409
A workaround is to add
@Transactionin the query method:Or you can rethink how you need to make this query to use simple annotations such as
@Query,@Delete, etc.An issue was opened requesting this feature to notify for changes when using
@RawQueryat https://issuetracker.google.com/issues/235878346, but no updates were made from the past 2 years.