Google calendar events have extended properties that can be used to attach name/value pairs to an event.
We are implementing a collaborative calendar application that uses those extended properties to attach extra information to the event. As recommended by Google, we use the Android CalendarProvider to read and create new events. When we create a new event we need to add some extended properties to it but we just realised that the calendar provider doesn't allow writting CalendarContract.ExtendedProperties
, if we try we get the following error:
Only sync adapters may write using content://com.android.calendar/extendedproperties
It seems a bit weird that these properties are read-only in the CalendarProvider because it defeats the whole purpose of them that is being able to attach some extra metadata to the event.
Does anyone know a workaround for this limitation?
you have to proceed as below :
the class you use for saving events with extended propeties should extends AbstractThreadedSyncAdapter , then implements the method onPerfomSync(...)
}
add the method below in the same class :
create a class that extends the Service class like below
}
In the res path create an xml file syncadpater.xml with the content :
The code for used for adding an Extendedproperties to you event, will be :
In the AndroidManifest.xml file add these permissions :
Then declare the Service that you've create into the manifest file associated to the syncadapter.xml file:
Good luck!