architecture-components-samples
architecture-components-samples copied to clipboard
[Question] Any examples of offline data saving to your backend using Room
I would like to do the following:
If I have a network connection then write new data to my backend and then make network call and pull data into Room DB, else if I have no network connection then write data into Room DB and then only write new data to my backend when I have a network connection.
Hope this makes sense.
Thanks, R
@rileymd88 , Why don;t you write all new data to the local db (i.e. room), then use a sync adapter to periodically (given connectivity etc.) sync the local db with the back end?
Some links that could prove useful: https://developer.android.com/training/sync-adapters/index.html https://developer.android.com/training/sync-adapters/creating-sync-adapter.html https://developer.android.com/training/sync-adapters/running-sync-adapter.html