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
0
votes
1 answer

How does a syncadapter delete data on the local db

I just had a little confusion about how a sync provider utilizes delete. After reading http://developer.android.com/guide/topics/providers/content-provider-creating.html#Delete, I implemented my own custom content provider, and I've written the…
user1549672
  • 486
  • 1
  • 6
  • 16
0
votes
1 answer

Can I add more than one period to perform a sync in Android syncAdapter?

I'm implementing a SyncAdapter and I need to synchronize a few times in a day but I also need the onPerformSync trigger a synchronization at midnight. ContentResolver.setIsSyncable(account, URIBuilder.AUTHORITY, 1); Bundle extras = new…
0
votes
1 answer

Adding a Calendar to a SyncAdapter Account for API 10 (2.3.3) to API (14)?

I have created a SyncAdapter along with authentication. Now that I am able to add a synced account to my device, I would like that account to be able to have Calendars associated to it. My SyncAdapter syncs to a custom calendar webserver I plan to…
0
votes
1 answer

Android SyncAdapter: retry

I'm using an AbstractThreadedSyncAdapter to synchronize some data with my server. I'm using SyncResult to indicate if there's been an error while performing the synchronization: syncResult.stats.numParseExceptions++; I initialize the SyncAdapter…
PX Developer
  • 8,065
  • 7
  • 42
  • 66
0
votes
1 answer

Add item in account menu

I have an application that has account in accounts and sync. I have option for synchronizing calendar and contacts. In the account there is menu in the upper right corner (standard like on all accounts). You can see what menu I'm talking about on…
nikmin
  • 1,803
  • 3
  • 28
  • 46
0
votes
1 answer

Automatic updates for app with and without SyncAdapter

I have a very common problem but wasn't able to find a proper solution/pattern to solve it. My application has two kinds of data that need to be automatically updated: general data user-related data If the user is not logged in, only general data…
0
votes
0 answers

Should SQLite queries be in Async Task Android

I am going to be implementing an abstractsyncadapter for my application by means of creating an account for the user using the account authentication. This means all of my REST method calls will be put into the sync service to be completed. My…
0
votes
1 answer

android: ContentResolver works on 4.0 but not on 2.3

In the contacts provider I'm building I want to create contacts group and then add the contacts to that group. This is my code for creating new group if one does not exist: if (groupId == 0) { // Sample group doesn't exist yet, so create it …
0
votes
0 answers

Android Contacts provider account interfering with other accounts

I've build a contacts provider which is synchronizing contacts from our private server. Everything is working fine until I delete the account. This is where the problem occurs. For example: If from my contacts provider account there is a contact…
0
votes
1 answer

How do I create a "Me" contact in android 4.0 and above

In my Sync Adapter for Android 4.0 and above, I want to create a "Me" account like Google+ and HaxSync are successfully creating. Googling all day long, I could find no way to identify this specific contact though. Is there a documented way to…
Hakan
  • 537
  • 4
  • 13
0
votes
1 answer

authToken in Android SampleSyncAdapter Sample

This piece of code is from AuthenticatorActivity in Android SampleSyncAdapter Sample project. It says, We store the authToken that's returned from the server as the 'password' for this account - so we're never storing the user's actual …
Binoy Babu
  • 16,699
  • 17
  • 91
  • 134
0
votes
1 answer

Android synchronisation - SyncAdapter or general Service for HTTP Basic Auth?

I want to synchronise a local Android database with a remote database on a server somewhere. For now, I want to do this via a REST API with basic HTTP authentication. I have done some reading and watched the Google I/O 2010 "Developing Android REST…
0
votes
1 answer

Using AuthenticatorActivity as application signin

My app requires a sync adapter and therefore requires some authentication to take place before an account can be added to the Accounts & Sync. I have followed the sample sync adapter app and have my app setup. I can for instance now verify a user on…
HGPB
  • 4,346
  • 8
  • 50
  • 86
0
votes
1 answer

Android SyncAccount / SyncAdapter add more options to account screen

How to add more options to sync account screen? Ex. how frequently do sync like in evernotes account settings, etc..
0
votes
0 answers

Android ContentProvider NOSQL Database

I'm trying to develop a custom contentprovider, that uses a NOSQL DB to store data, because the static columnmodel of sqlite doesn't fit to my needs. I have found out that CouchDB provides a mobile version for Android called TouchDB, I also found an…
Nickolaus
  • 4,785
  • 4
  • 38
  • 60