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

SyncAdapter onPerformSync doesn't always get called

I built a SyncAdapter for my app so that I could use Google Cloud Messaging to trigger a sync of database to the server. I am using Volley to actually make the network calls and sync the data, but from what I read when wanting to sync your app you…
Ephraim Schmitt
  • 227
  • 2
  • 16
0
votes
1 answer

Android account sync disabled after application update

I've noticed that when my application gets updated from some version A to version B, sync checkbox next to my account (in Accounts system settings) gets disabled. A and B are subsequent commits, and the problem does not occur when updating from…
0
votes
1 answer

Android sync service destroyed when app is closed

I am using sync adapter on my app to perform periodic sync . But the problem is when a sync is running , and I close the app at that time , sync stopped . As far as I know sync adapter always run on background , closing the app won't affect sync…
aroSuv
  • 127
  • 3
  • 14
0
votes
2 answers

ContentProvider and multi-threading

I've been thinking about this scenario. Let's say I have a SQLite database wrapped in a ContentProvider, The data in the database is sent to a webservice thorugh a SyncAdapter which runs every 10 minutes. To know which rows have been sent to the…
0
votes
1 answer

Manual sync button is missing in android sync adapter

I have created my own sync adapter . And I want to enable manual sync on it so that user can syn when they want . But the manual sync button is not showing . As we can see that that there is a sync button on the left of checkbox , but in my case…
Mithun Sarker Shuvro
  • 3,902
  • 6
  • 32
  • 64
0
votes
1 answer

Sync adapter in android without content provider and authentication account

I am trying to implement a sync adapter in my app . My app fetch data via REST API , when my app run initially it fetch the data via REST API and set it on my local database . I am now planning to make a sync adapter , by which my app will sync data…
Mithun Sarker Shuvro
  • 3,902
  • 6
  • 32
  • 64
0
votes
1 answer

onPerformSync called on emulator but not physical device

I've built an Account sync adapter to show contacts from the app in local contact book. There is a fake authonticator that provides account. Also account is syncable ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1); …
dilix
  • 3,761
  • 3
  • 31
  • 55
0
votes
1 answer

SyncAdapter only syncs once

I have a big problem with my sync adapter. In a first step, I want to call sync everytime, a special activity is resumed (very inefficient, I know but its only for testing). When I call my ContentResolver.requestSync the first time after starting…
KCD
  • 678
  • 5
  • 20
0
votes
1 answer

Using AbstractThreadedSyncAdapter before api 11

How do I use AbstractThreadedSyncAdapter for minSDK lower than API-11? The following constructor is complaining about needing API-11. public DogSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) { super(context,…
learner
  • 11,490
  • 26
  • 97
  • 169
0
votes
1 answer

best way to kill Android app in onPerformSync() (SyncAdapter)

I have a SyncAdapter extending AbstractThreadedSyncAdapter . I want to clear cache (no problem) and kill the app in onPerformSync(), what would be the best way to kill the app in onPerformSync() ? Thanks.
hixhix
  • 771
  • 7
  • 23
0
votes
1 answer

Architectures for RESTful Android Applications

I'm currently developing an Android application and I'd like to have an scalable architecture with a clean separation of concerns. The requirements of this application are, mainly: User autentication (I'm dealing now with Google Sign-In for Android…
Juan
  • 2,156
  • 18
  • 26
0
votes
1 answer

How to know if the data on the server is newer than the data on the device, or vice versa?

I have been trying to implement SyncAdapter to sync data between client(android device) and server using sqlite.The same data will be shared between different devices. On Update: As soon as a particular record is updated on one client device it…
ThunderDragon
  • 613
  • 3
  • 13
  • 31
0
votes
1 answer

Store on database vs Retrive data from network

I working on my app that uses "The movie database API". This app just parse a json from the API and gets each movie information. My question is what the better way to that. First alternative is to build syncAdapter, check for updates each day for…
Roman Pozdnyakov
  • 408
  • 1
  • 4
  • 17
0
votes
1 answer

Scheduling background sync jobs in Android (API > 15)

We have a requirement to schedule periodic sync jobs for an Android Application. There is no hard schedule requirement but as long as the sync runs every 6-7 hours, it should be fine (provided there is network connectivity). We're using…
0
votes
1 answer

Error inflating a fragment

I am currently trying to get the hang of sync adapters and trying to get the Google sync adapter example working. I keep getting tons of errors on it. Does anyone have any idea how to fix these or a better functioning sync adapter I could look at? I…