Question: I have implemented an android application which retrieves data from database hosted outside and save it locally on the device.  

What I need to do is check every day for changes in the hosted database and based on changes the application will update the local SQLite database.  

**My question:** I need to check in background any changes on database daily, at the moment when the job starts and there is an internet connection it will check and stop and rerun the next day, if there is currently no internet connection the job must check every 10 min until an internet connection is available.  
 Also I need the job to not to be effected if the device reboots.

If someone can provide me with small demonstration code since I am a beginner in android development this will highly appreciated.

Answer: 
What you are looking for is a `SyncAdapter` which performs in the background idependently from the application, it will give you all the possibilities you are asking for.  

To get into the topic watch this video it explains everything pretty good:   
<https://www.youtube.com/watch?v=xHXn3Kg2IQE>   

And take a look at the links in the answers of this question:  

[Own sync adapter for Android?](https://stackoverflow.com/questions/1859241/own-sync-adapter-for-android)
You can use Job schedule in Android, pre Lollipop there is Firebase job schedule, this save data, time and battery you can check more here

<https://developer.android.com/reference/android/app/job/JobScheduler.html>