I
I
IvanOne2016-01-25 17:06:59
Android
IvanOne, 2016-01-25 17:06:59

How to update the base in the background?

Hey! I recently started learning android, I wrote my mini application and now the task is to synchronize with the server via http, that is, the algorithm is like this, I create an entry or update it directly from the application, I try to start synchronization, but in a separate thread if there is no access to the network or interruptions then do nothing with the server, if everything is OK, then give the data, you can get new ones and write it to the database. At the same time, the same synchronization task should be performed in the background by a timer (for example, once every 20 minutes), even if the application is closed. Here that interests:
1. What classes to use? Watched examples at all all on a miscellaneous
2. If the user addresses a DB and at this moment there is a synchronization in a separate flow what will be? mistake?
I can be wrong and choose the wrong words, correct me if anything, advise how you can do such a task.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Gamega, 2016-01-25
@IvanOne

At the same time, the same synchronization task should be performed in the background by a timer (for example, once every 20 minutes), even if the application is closed.

Very bad idea, send gcm if there is an update
Something for asynchrony, you can just IntentService
I like to use retrofit + gson for rest requests
To work with the ContentProvider database - yes, it has a disgusting api but it works very stable
sqlite works on the principle of a lot of reading one writes, but this can be solved with additional connections to the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question