Answer the question
In order to leave comments, you need to log in
How to properly wrap work with the REST API and the Room database in threads?
In my application, I implement work with the REST API using Retrofit, and work with the database using Room , the application is built on the MVVM pattern. Networking and database work can be very UI intensive, which I would like to avoid. Please tell me how it would be better for me to arrange the work with these "heavy" tasks in separate threads, which classes should be paid attention to. Videos, articles, your personal advice, I will be glad to everything))
Answer the question
In order to leave comments, you need to log in
Retrofit itself goes to the network on the background, the system will not let you go to the network on the ui thread.
As for the room - it seems that it also does not allow you to go into yourself with a ui thread, in any case, they write so on the Internet. I haven't worked with it myself, so I'm not sure.
Pay attention to RxJava or Kotlin coroutines.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question