Questions tagged [android-syncadapter]

An Android service that synchronizes data between an Android device and a server

A SyncAdapter is an Android Service that synchronizes data between an Android device and a backend server. SyncAdapters can be part of an Android program, or can be a standalone entity. SyncAdapters are associated with an Account, which defines a collection of data that belongs to a specific application.

The purpose of a SyncAdapter is to ensure that data is kept consistent on the Android device and a server. When the data is changed on the server, the SyncAdapter must identify that a change has been made, and update the data on the Android device to reflect the change.

The most common type of data that is synchronized using SyncAdapters are your Contacts list. Whenever you add a contact on your phone, the contact is also sent to the Google server and stored within. Similarly, if you add a contact from a different Google service, such as GMail, the SyncAdapter will identify that a contact has been added, and replicate the data onto your Android device.

Any type of data can be synced with a backend server, its only dependent on the type of data that your application is dealing with. Other common data types to be synced in this way are Calendars and To-Do/Task lists.

The reason why SyncAdapters exist is to create a local copy of the data, so that it can be accessed quickly without the need for a data connection. For example, if your contacts are kept synced, then you can access your contacts quickly on your Android device regardless of whether you have data access or not - it's all locally-stored data independent from network requirements.

SyncAdapters will usually send a 'check' message to the server on a periodic basis, say every 30 minutes, to ask whether any changes have been made during this time. This is only a small data exchange, and doesn't consume much network data. Further 'synchronization' steps only occur if the data has changed and needs to be updated on the Android device accordingly.

SyncAdapter Class Reference

606 questions
14
votes
1 answer

Prevent network sync loop when syncing from network in Android ContentProvider

I'm writing my own ContentProvider which will be synced to a web service using a SyncAdapter. Problem happens when the sync adapter is modifying the content provider's data the provider triggers a network sync when internally calling…
m1h4
  • 1,139
  • 2
  • 13
  • 22
14
votes
3 answers

SharedPreference committed in SyncAdapter not updated in Activity?

I am changing and committing a SharedPreference in my SyncAdapter after successful sync, but I am not seeing the updated value when I access the preference in my Activity (rather I am seeing the old value). What am I doing wrong? Different…
matsch
  • 549
  • 4
  • 10
14
votes
4 answers

Otto/EventBus across multiple processes

Is it possible to post event in one process (for example inside SyncAdapter which has android:process=":sync" manifest attribute) and receive it in another (inside regular app UI) with Otto or EventBus? I know that Intent and BroadcastReceiver work…
svenkapudija
  • 5,128
  • 14
  • 68
  • 96
14
votes
2 answers

Contact sync adapter in android

I want to use sync adapter in my application to sync the native and third party contacts (except FB) with server. ( Only client to server one way sync) I have two doubts here - 1) If there are multiple sync adapters in the device and If dirty bit…
Jambaaz
  • 2,788
  • 1
  • 19
  • 30
14
votes
2 answers

Show settings under accounts & sync menu for android app

I am implementing a syncadapter for an android app and would like to make the settings for the account available under the "Accounts & sync" menu. I have seen this done in the DropBox app(as shown below), but I have not been able to find…
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
13
votes
2 answers

Flutter Syncing LocalDB With RemoteDB

I have data stored locally in sqlite. I have a remote MySql server. In android I could setup SyncAdapter to handle the syncing between the localdb and the remotedb. When a record is saved locally and there is an internet connection it should push…
user3718908x100
  • 7,939
  • 15
  • 64
  • 123
13
votes
4 answers

In Android, should a contact sync adapter run in a separate process?

In my app, I'm using a contact sync adapter, but it has a lot of information that it shares with the main app. There are settings that the adapter needs to work proplery (like login information and if the user changes any sync settings), so I…
user496854
  • 6,461
  • 10
  • 47
  • 84
12
votes
3 answers

AccountManager does not add custom account in Android N preview

I have implemented a sync adapter in my app which requires an account to be added in the device account settings. I followed the same approach given in the Android docs. It works fine till Marshmallow and I can see my account listed in the device…
12
votes
1 answer

SyncAdapter always in pending state

I'm currently working on an android app which relies on a SyncAdapter to refresh its content from a server. I basically followed these instructions: https://developer.android.com/training/sync-adapters/creating-sync-adapter.html This worked…
12
votes
2 answers

SyncAdapter vs JobScheduler

Excluding the fact that JobScheduler only supports API > 21 - are JobSchedulers designed to fully replace SyncAdapters? Or does SyncAdapter contain any functionality lacking by JobScheduler? My use case is syncing an RSS feed every couple of hours.…
12
votes
1 answer

Android Calendar Provider: Is there a unique identifier for events, usable across multiple devices?

I'm using the Android Calendar Provider to display events. I'm also associating the events with images from a local app database by using the EVENT_ID of the event as a reference. I'm now wondering if it is possible to keep the same reference across…
11
votes
1 answer

Android Sync Sqlite

I am making a dictionary kind of an app which uses SQLite. I have a single table that keeps the pair of foreign words and their translations. I want to sync this table with a particular spreadsheet in Google Docs. I ve found this awesome library…
11
votes
1 answer

How to add custom app tag in native android contact app?

I am developing an app and the requirement is to show the app icon in native contact app of android for the contacts who are also using my app i.e. they have installed and registered on my app. I want to show WhatsApp kind label in contacts. Please…
11
votes
2 answers

Android multiple sync adapter items like Google Account?

I currently have my Android app set up to use the AccountManager feature of Android, using a SyncAdapter and an authenticated account to performs syncs automatically. I only have 1 sync adapter running which syncs all content, but I would like to…
11
votes
2 answers

Desiging an Android App with Offline Sync. Should I use SyncAdapter?

I'm trying to make an Android To-Do client for a web service, with offline caching and sync. The web service returns data in JSON format about To-Do tasks on the server when you send it a post message. To add a To-Do on the server, you need to send…
karthik
  • 133
  • 1
  • 1
  • 7
1
2
3
40 41