When I create a Google Calendar event and attach extended property to it, all is working as expected - both event and its extended property get synced so they can be accessed from different devices. Here is the code:
// create event with extended property
ContentValues values = new ContentValues();
...
values.put(CalendarContract.Events.HAS_EXTENDED_PROPERTIES, 1);
Uri eventURI = contentResolver.insert(CalendarContract.Events.CONTENT_URI, values);
long eventID = Long.parseLong(eventURI.getLastPathSegment());
Uri extendedPropertyURI = CalendarContract.ExtendedProperties.CONTENT_URI;
extendedPropertyURI = extendedPropertyURI.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CalendarContract.Events.ACCOUNT_NAME, "...")
.appendQueryParameter(CalendarContract.Events.ACCOUNT_TYPE, "com.google").build();
ContentValues extendedValues = new ContentValues();
extendedValues.put(CalendarContract.ExtendedProperties.EVENT_ID, eventID);
extendedValues.put(CalendarContract.ExtendedProperties.NAME, "name");
extendedValues.put(CalendarContract.ExtendedProperties.VALUE, "valueA");
contentResolver.insert(extendedPropertyURI, extendedValues);
Now I want to update my extended property, let's say replace "valueA" with "valueB", here is what I do:
// update extended property
int propertyID = 123; // got this ID from CalendarContract.ExtendedProperties._ID, let me omit the code
ContentValues updatedValues = new ContentValues();
updatedValues.put(CalendarContract.ExtendedProperties.VALUE, "valueB");
Uri updateUri = ContentUris.withAppendedId(extendedPropertyURI, propertyID);
contentResolver.update(updateUri, updatedValues, null, null);
The extended property value gets updated successfully, I can see "valueB" on the device where the update has been executed. But it never syncs with Google Calendar server so other devices always show "valueA". I can observe the same behavior when I am trying to add another extended property to the same event - I can see both extended properties on current device only. New extended property never gets synced.
Can anyone please help to understand what I am doing wrong? I need to be able to add multiple extended properties to an event as well as edit these properties later.
P.S. Instead of attaching one single initial extended property, I could attach multiple extended properties to a new event in a loop, they all will be synced across devices successfully:
for (int i = 0; i < 10; i ++) {
ContentValues extendedValues = new ContentValues();
extendedValues.put(CalendarContract.ExtendedProperties.EVENT_ID, eventID);
extendedValues.put(CalendarContract.ExtendedProperties.NAME, "name");
extendedValues.put(CalendarContract.ExtendedProperties.VALUE, "value" + i);
contentResolver.insert(extendedPropertyURI, extendedValues);
}
So the syncing issue only occurs when I am trying to update an existing property or add (not at same time in a loop!) a new property to an event which already has "initial" extended properties.