Home > Mobile >  Android room how to return a flow of Map where the map value can be a pair or an object?
Android room how to return a flow of Map where the map value can be a pair or an object?

Time:10-12

I have a table like this:

data class ChapterDetails(
   val id: Int,
   var correctAnswersCount: Int,
   var totalQuestionsCount: Int,
   // ... ... ...
)

I would like to return a Flow<Map<Int, Pair<Int, Int>> > from the room dao. I saw this enter image description here

  • i.e.

    • first is empty as expected (now rows exist at that point)
    • second has the expected data from the first row
  • You just need to adapt it to use Flow

  • Related