本文介绍了如何连接专用数据到Android的日历事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何可以附加一些额外的数据,以日历的事件,例如文件,照片,一个简单的字符串等。

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);

它正常工作了Android 2.2 ...同样code如果在的Andr​​oid 4.0(冰淇淋三明治)进行测试。它抛出一个错误,说只有同步适配器可以访问的内容://com.android.calendar/extendedproperties

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.

所以我exectued查询作为callerissyncadapter。我现在能够插入扩展属性。但是,一旦事件被同步到服务器,扩展属性正在由服务器中删除。

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)

有没有什么办法可以附加一些额外的数据日历事件以外extendedproperties,或者我们可以利用这个扩展属性更更好的办法。

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.

推荐答案

不要使用callerissyncadapter,除非你真的是同步适配器。将其设置为true,将会导致内容观察员不能在供应商变更内容的通知在设备上,使您的更改不会被保存到服务器。

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.

这篇关于如何连接专用数据到Android的日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:01