Hi guys , I want to do some data syncing like calling a api and then inserting the data into room da...
d
Hi guys , I want to do some data syncing like calling a api and then inserting the data into room database. What will be the best approach for this? 1. GlobalScope 2. Work manager 3. Service
not kotlin but kotlin colored 6
If there are other options please let me know.
c
Wrong workspace. Over here we talk about the Kotlin programming language and all related topics. You question is pure android and should be asked on a different platform.
a
To answer your question anyways: It depends on your usecase, if the data does not need to be up to date to the minute you should use workmanager so the system can schedule the update to when its convenient. A service would only be required if you need to update the data in the background and at a very specified time (not for example once a day, no matter when). GlobalScope should only rarely be the answer, you should rather use MainScope but that would probably wrong too, since even the MainScope will only live as long as the app is running.
m
WorkManager !