Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How attach private data to android calendar event

How can we attach some extra data to a calendar event like files,photos,a simple string etc,..

i used extended properties and able to insert some extra data via extended properties

Uri extendedProperties=Uri.parse("content://com.android.calendar/extendedproperties");
ContentValues extendedValues=new ContentValues();
extendedValues.put("event_id", id);
extendedValues.put("name",key);
extendedValues.put("value",value);
getApplicationContext().getContentResolver().insert(extendedProperties, extendedValues);

and later able to retrieve that data like below

Uri extentdedProperties=Uri.parse("content://com.android.calendar/extendedproperties");
CursorextendedPropertires Cursor=getContentResolver().query(extentdedProperties,null,"event_id = "+Id +",null,null);

It works fine with android 2.2 ... Same code if tested in android 4.0 (ice cream sandwich). It is throwing a error saying that only sync adapters can access content://com.android.calendar/extendedproperties.

So i exectued the query as "callerissyncadapter". Now i am able to insert extended properties. But once event is synced to server , extended properties are being deleted by the server.

Even these extended properties are not fully supported by calendar providers (other than google)

Is there any way to attach some extra data to calendar event other than extendedproperties or can we make use of this extended properties in a more better way.

like image 320
Sai mukesh Avatar asked Feb 20 '12 13:02

Sai mukesh


1 Answers

Do not use callerissyncadapter unless you are really the sync adapter. Setting this to true will cause content observers on the device to not be notified of changes to content in that provider and for your changes to not be persisted to the server.

Why are you trying to do this? Are you trying to associate some data for your app with a calendar event?

If so, why not create your own, private data store (or content provider) with your application and index your extra properties by the key of the events in the calendar content provider? This way, you have an association between your app's data and the public contacts content provider data.

like image 138
Warlax Avatar answered Nov 07 '22 13:11

Warlax