Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:syncable=true for a ContentProvider?

Tags:

android

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

like image 599
giladgo Avatar asked Feb 24 '15 13:02

giladgo


1 Answers

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?

like image 195
rds Avatar answered Oct 05 '22 13:10

rds