Is it possible to run the SyncAdapter in the background even when the application is not running? I want to update the sqlite database if there is any changes in the server , even when android application is not running?
Probably the best practice for this use-case is:
1) Fire a
Broadcast from your server, whenever the data changes.
2) Start a service from the broadcast receiver. (you can send some extra data with your broadcast to distinguish between broadcast operations).
3) Update your database in your started service.
If the above solution is not an option, then:
I would recommend you to use JobScheduler which is a newer and recommended approach for such use-cases.
Although, you can also achieve your goal using SyncAdapters. But nowadays, they are usually used when you need to maintain accounts or share AuthTokens between other apps or store some
SyncAdapter specific data in your