12

While trying to understand Android's SyncAdapter/ContentProvider framework, one thing still eludes me. I don't understand why a ContentProvider needs android:syncable="true" to be defined in the manifest.

Why does a ContentProvider need to know if it will be used from within a SyncAdapter?

The Google docs say: "The flag allows the sync adapter framework to make data transfers with the content provider, but transfers only occur if you do them explicitly."

Does that mean that if I don't specify android:syncable="true", I can't use the ContentProvider in the SyncAdapter's onPerform? If so, how can the framework even enforce such a thing?

Can someone help me shed some light on this subject?

Thanks

giladgo
  • 393
  • 3
  • 12
  • 1
    possible duplicate of [ContentProvider won't show up in Data & Synchronization area](http://stackoverflow.com/questions/5619101/contentprovider-wont-show-up-in-data-synchronization-area) – Maveňツ Feb 24 '15 at 13:56
  • So you're saying that without `syncable=true`, nothing will appear in the Accounts area? I tried explicitly setting it to `false` and it's still there... – giladgo Feb 24 '15 at 14:12
  • 1
    Good question, wondering this myself. – Daniel Oct 09 '15 at 11:17
  • If set to `true` , you don't have to call `setIsSyncable()` in your code. They are the same, its like a switch that allows for data transfer, but the transfer part will still have to be done explicitly. – Vrashabh Irde Oct 19 '15 at 08:10

1 Answers1

1

A ContentProvider doesn't need android:syncable to its associated SyncAdapter.

And you ask:

Does that mean that if I don't specify android:syncable="true", I can't use the ContentProvider in the SyncAdapter's onPerform?

That's not what it means.

From the doc, android:syncable defines

Whether or not the data under the content provider's control is to be synchronized with data on a server

AFAIK, you can define a ContentProvider without a SyncAdapter – the opposite is false, see also What should I use Android AccountManager for?

Community
  • 1
  • 1
rds
  • 26,253
  • 19
  • 107
  • 134