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

602 questions
268
votes
9 answers

Sync data between Android App and webserver

I want to sync data (such as db record, media) between an Android App and a Server. If you've seen Evernote or similar Applications, you certainly understand what I mean. I have some question (imagine we want to sync DB records): Every user has a…
Omid Nazifi
  • 5,165
  • 8
  • 28
  • 55
113
votes
2 answers

Why does ContentResolver.requestSync not trigger a sync?

I am trying to implement the Content-Provider-Sync Adapter pattern as discussed at Google IO - slide 26. My content provider is working, and my sync works when I trigger it from the Dev Tools Sync Tester application, however when I call…
Ben
  • 1,674
  • 2
  • 14
  • 21
53
votes
3 answers

How do I use the Android SyncAdapter?

I try to understand the Android synchronization logic. What I don't understand is the file syncadapter.xml contained in the Android SDK sample project SampleSyncAdapter. If you downloaded the SDK samples it should be in the following…
xpepermint
  • 31,091
  • 29
  • 106
  • 160
38
votes
2 answers

SyncAdapter without a ContentProvider

I want to implement a SyncAdapter for a content I want to synchronize with a server. It seems that to do so, you need a ContentProvider registered for the authority you specify in the SyncAdapter XML property file. As I don't want this content to be…
Moystard
  • 1,807
  • 2
  • 17
  • 18
26
votes
6 answers

Up-Sync and Down-Sync in Android?

I am working on a Point of Sale application that needs to be very good syncing mechanism. We have Magento Database.The android device have SQLite local Db. Now we need to sync in the following way: Local ------Sync To---------------> Server (Up…
24
votes
2 answers

Hide dummy Account for Sync Adapter from Settings

I have created a Sync Adapter with a dummy Account and I don't want it to appear on the Account list in the Settings application, nor when a user presses the add account button in Settings. I have tried android:userVisible="false" in my sync-adapter…
Astagor
  • 299
  • 2
  • 8
23
votes
1 answer

How can I enable the sync option by default when false in app?

I use odoo mobile framework. How can I enable the sync option on app startup? (The option is disabled by default.)
Naitik
  • 960
  • 11
  • 31
21
votes
2 answers

How to handle RESTful update of remote server with SyncAdapter

I've watched the Google I/O REST talk and read the slides: http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html I'm still a bit unclear on how to nicely handle, say, an update error thrown by the remote server. I have…
21
votes
1 answer

When SyncAdapter runs synchronization on android?

Let's say, my application implements SyncAdapter functionality and doesn't define periodic syncs. When synchronization will happen in such scenario? First scenario I may think about is local ContentProvided/database content change. What is about…
LA_
  • 18,018
  • 53
  • 160
  • 288
21
votes
7 answers

Own sync adapter for Android?

The press release of Android 2.0 states that the new release supports sync adapters so that emails and calendars cannot only be synced with gmail and exchange. However, there is no information available online how to write such a sync adapter. Has…
Seba
  • 211
  • 1
  • 3
  • 3
19
votes
3 answers

Why might AccountManager.addAccountExplicitly return false?

Google's Android docs (http://developer.android.com/reference/android/accounts/AccountManager.html#addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle)) say: Returns True if the account was successfully added, false…
cja
  • 10,504
  • 18
  • 66
  • 120
18
votes
1 answer

Android SyncAdapter use case

What we are doing currently? We have some structured, textual data on a server which is exposed using web services(RESTful). My application polls this server regularly(AlarmManagerService) to fetch the data and save it on local database(sqlite).…
Samuh
  • 35,513
  • 26
  • 104
  • 116
17
votes
1 answer

Login in twice when using SyncAdapters

I am creating a new Android app using SyncAdapter to handle db sync. I have everything in place and the app is working fine but I noticed that I am logged in twice. The first login takes place when the AuthenticatorActivity class (it extends…
Macarse
  • 87,001
  • 42
  • 169
  • 229
15
votes
3 answers

SyncAdapter alternatives

I think its well known that in list of worst-documented topics, SyncAdapter shines bright like a diamond ! acording to http://udinic.wordpress.com/2013/07/24/write-your-own-android-sync-adapter/ SyncAdapter brings 4 main benefits : A) Battery…
Shervin
  • 223
  • 1
  • 12
15
votes
4 answers

Android SyncAdapter Automatically Initialize Syncing

I have a SyncAdapter for my app, and an AccountManager to add my apps accounts to the Android Account Manager. My code for when I add an account to the Account Manager looks like: Bundle data = new Bundle(5); data.putString(_PEOPLE_ID,…
Dandre Allison
  • 5,795
  • 5
  • 39
  • 55
1
2 3
40 41