endian
endian

Reputation: 4879

Syncing multiple providers with one SyncAdapter

I want to sync com.android.contacts and com.android.calendar with one SyncAdapter. Is this possible?

If yes, how I have to edit following lines?

<sync-adapter
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.android.contacts"
    android:accountType="com.package.account"
    android:supportsUploading="false"
    android:userVisible="true" />

Upvotes: 5

Views: 2429

Answers (2)

Vasiliy
Vasiliy

Reputation: 16268

You can sync any ContentProvider from your SyncAdapter, as long as it is exported and allows for modification of the underlying data.

In order to accomplish this you DON'T need to specify the extra providers or authorities in your XML - just get a reference to ContentResolver inside onPerformSync() and use it to access ContentProviders of interest.

For a bit more info, read this answer: https://stackoverflow.com/a/30693866/2463035

Upvotes: 1

Phil
Phil

Reputation: 320

Appearently not:

"Each SyncAdapter spins up a SyncThread that is bound to the authority defined in sync-adapter.xml, and multiple authorities cannot be defined in this xml file..."

(kianatennyson)

How to use one SyncAdapter-class for multiple authorities?

Upvotes: 3

Related Questions