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

Sync android app data between devices using some host

I have a little android app that creates schedules for teams. For instance there is team of 9 and one user creates schedule with names of all members of his team on android device. How can this user share the result with others. I see this like he…
Dmitry Smolyaninov
  • 2,159
  • 1
  • 18
  • 32
0
votes
1 answer

SyncAdapter without ContentObserver

I recently learned that when using a ContentProvider with CursorLoaders, there is no need to create your own ContentObserver, you just call cursor#setNotificationUri() or getContext().getResolver().notifyChange. Now i want to use a SyncAdapter to…
lll
  • 173
  • 15
0
votes
1 answer

Is there any way to call onPerformSync() when there is no internet connection on device

Its seems like a weird question but still I want to call onPerformSync() or periodic sync when there is no internet connection on device. I have gone through some discussions here and found that onPerformSync will not be called when device is in…
Abhimanyu Raj
  • 73
  • 1
  • 9
0
votes
2 answers

How to sync data in AbstractThreadedSyncAdapter with Firebase?

I am trying to sync data from firebase using AbstractThreadedSyncAdapter. For that I have written some firebase onPerformSync method. The problem is that as soon as this method is called app crashes. Error on logs: FirebaseApp with name [DEFAULT]…
0
votes
3 answers

SyncAdapter - How to Periodic sync every second

I'm trying to force my application to perform a sync every second, or just every 4 or 5 second. However, the minimum period i can make the syncadapter sync is 30-60 seconds. How can archive such a behavior? No matter what i set i the second…
user1868569
  • 23
  • 1
  • 7
0
votes
1 answer

Bi-directional synchronization using Android Sync Adapter

Classic problem: Having a database on the server and a database on Android that both have to be kept synchronized (with a REST service). After a lot of research it seems to be quite a good idea to use Android's Sync Adapter. I came over it reading…
jublikon
  • 3,427
  • 10
  • 44
  • 82
0
votes
0 answers

Android sqlite id missing after update

after I update an object in my syncAdapter I can't get it back by id again. It seems that the id get lost after the update. What leaves behind is a null object. Here's my source code how I update the object: @Override public void…
Johannes N
  • 265
  • 3
  • 17
0
votes
3 answers

addPeriodicSync does not work

Have an issue with using of SyncAdapter. I've created it as in this guide, but when I try to use addPeriodicSync I don't get any effect. I read all answers which I found on Stack Overflow but still don't have any idea where is the trouble. Kindly…
Igor Dotsenko
  • 85
  • 1
  • 8
0
votes
0 answers

Exclusivity of an android sync adapter

If I use a sync adapter for built in android calendar, what exclusivity do the sync adapter have? What if some other sync adapter want to interact with the calendar as well, what would happen?
user3357751
  • 101
  • 1
  • 10
0
votes
1 answer

What exactly gets executed on Android device when you check Settings > Accounts > Google account > Sync Calendar?

On Android device, when you go to Settings > Accounts > your Google account > and check Sync Calendar, what exactly gets executed? I suppose there must be something like a built in sync adapter which connects to the Google Calendar server, gets the…
0
votes
1 answer

Using BroadcastReceiver to launch SyncAdapter

I am trying to use a BroadcastReceiver to trigger the SyncAdapter when there are changes in the database server (using GCM). When the receiver is told to start the sync process, I get the following error ContentResolver.requestSync(accounts[0],…
0
votes
1 answer

Structure for Android app with complex database

Be kind this is my first question on StackOverflow :p. I am hoping its specific enough. Here is how the project is structured REST API built using NodeJS and MongoDB (mongoose has been used for modelling the database schemas) with a Express…
0
votes
1 answer

Does SyncAdapter (with stub ContentProvider and Authenticator) not need account permissions anymore?

I am dealing with runtime permission requesting for my app so that I can upgrade to API 23. From trial and error, it appears that the GET_ACCOUNT and MANAGE_ACCOUNT are no longer required for SyncAdapter with stub ContentProvider and…
Asd
  • 303
  • 2
  • 7
0
votes
1 answer

Is it possible to add another sync account to an existing contact in android?

What I want to do is creating a sync app and I'm doing it based on sync framework guideline now I am in a point that I don't want to do all the tedious job hence looking for a shortcut. I want to add my sync account to existing contacts rather than…
Vahid Hashemi
  • 5,182
  • 10
  • 58
  • 88
0
votes
1 answer

System notification from SyncAdapter:onPerformSync

I have sync adapter that performs some operation in background. To notify my main activity about sync operation status, I used broadcast receivers, so my activity is able to receive messages from sync adapter. It works fine. However, I also need to…
user1209216
  • 7,404
  • 12
  • 60
  • 123