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
2 answers

Android SyncAdapter and concurrent write accesses

I am developing a RESTful Android app using SyncAdapter. I have watched some screencasts and read some tutorials, but they only address basic dynamics. Before starting to write the code, I would like to try and receive feedback from expert users…
Antonio Sesto
  • 2,868
  • 5
  • 33
  • 51
0
votes
1 answer

Android - SwipeRefreshLayout calls a REST API, parses the json and show the results

I have a SwipeRefreshLayout with a listview, so when the user swipes it, I want the app to retrieve json data from a rest server (PHP), parse it, put the data inside the adapter and show the result inside the listview. My question is regarding the…
0
votes
1 answer

Android - get application account outside SyncAdapter (handle sync options)

How to get application account that I create? In my SyncAdapter I have account in onPerformSync method, but how I can get the account outside SyncAdapter without adding GET_ACCOUNTS permission, for ex. in MainActivity? The target is that I want to…
miecio
  • 315
  • 1
  • 4
  • 19
0
votes
1 answer

Android : How to do sync data automatically

In my application I will get large amount of data from the server. I want to sync all the data by automatically with the device. Even when my app is not in use, I want to sync the data. Right now I have done that by using AsyncTask. But it is taking…
0
votes
1 answer

How to synchronize android device to web server?

I want to upload my images,video and contact to server for backup.Which is optimize way to do this? I try to use sync adapter to upload all these things but problem occur in implementation.Please help me.Thanks in advance.
0
votes
3 answers

AsyncTask dialogBuilder error

So in my app, I want to implement an auto-upgrade feature so that my app's users can upgrade the app easily. In order to do that I decided to use my syncAdapter (already usable for updating local SQLite from a remote mySQL Server). So in my…
user1137313
  • 2,390
  • 9
  • 44
  • 91
0
votes
1 answer

Can a single Sync Adapter be used for multiple Database Tables?

I need to send bulk of data to my database on server from Android app, and need to sync it periodically. I went through Sync Adapters sample code on Android Developer's website, but couldn't get the concept and usage. I need help regarding: how it…
0
votes
1 answer

Run ContactsSyncAdapterService from outside Android app

If an app has an exported service in the android manifest that means I can run that service from within another app right? For example the service looks like this in the manifest file.
0
votes
1 answer

Android: Insert/Update/Delete contact

I am developing an application in which I list the device contacts, and perform some manipulation with them. I listen to contact changes as described in the following links: Link 1, Link 2 My code is as follows: public class ContactService extends…
0
votes
1 answer

Incorrect values when I select a radioButton in ListPreference

I have a Preference activity which uses a List Preferences as defined by my XML file:
ilyamuromets
  • 403
  • 1
  • 7
  • 18
0
votes
1 answer

SyncAdapter is not considering static variables set by Main thread

Android SyncAdapter is not considering static variable values set by main thread. As static variables persist through application, it is expected to share across threads. But SyncAdapter is not considering those values set by main thread and taking…
0
votes
1 answer

Account settings without app preferences activity

Sorry for my bad English! I am implemented a syncadapter an android app and want to make account settings, such as Google accout settings. Google account has three groups of settings (search, location, ads), each of them opens a separate activity. I…
ilyamuromets
  • 403
  • 1
  • 7
  • 18
0
votes
2 answers

Android: Design consideration for periodic syncing with Sync Adapter

I am using sync adapter in my app. The app should perform a sync at every 3 hours. This can be done with ContentResolver.addPeriodicSync. But, prior to that, with every sync request I need to send the access token of the user. The token's expiry…
Nitish
  • 3,097
  • 13
  • 45
  • 80
0
votes
1 answer

Activity for Settings "Add account" option on Android

Using the SyncAdapter framework, my app is showing in the add account option in the settings menu: When I select "Add account" I can see my app in the list but selecting it just freezes the settings. I guess I should tell the setting what activity…
Ran
  • 1,089
  • 1
  • 12
  • 30
0
votes
2 answers

Sync Adapter with Content Provider Data Looping and deleting

I'm trying to work with ContentProvider and SyncAdapter, I got all my files setup and all, it's working fine. What I'm actually doing is that, I'm using the syncadapter to to send data to my Server, but I want it to delete it after sending, but…
user3994005