Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Does Android Room wait for withTransaction block to finish before proceeding to next line
class MyViewModel(private val db: AppDatabase): ViewModel() {

    suspend fun insertAndRead(pages: List<Page>) {
        db.withTransaction {
            db.pageDao().insertAll(pages)    
        }
        val pagesInserted = db.pageDao().selectAll()
    }
}

I'm curious about the Room handles the withTransaction block.

Let's say with the code example above. Does Room wait for the withTransaction block to finish running, then go to then next line?

Or it simply runs the withTransaction block inside a coroutine, then starting the next line immediately without waiting for the withTransaction block to complete?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

withTransaction() is a suspend function. Suspend functions generally wait by suspending, they are synchronous to their callers, they don't schedule asynchronous operations.

So the answer is: yes, it waits for the inner block to finish executing.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!