从我的Andr​​oid日历中删除定期事件的一个实例我的、实例、日历、事件

2023-09-08 08:58:10 作者:藍海雲天

我一直在寻找通过关于如何从我的Andr​​oid 2.3手机的日历中删除定期事件只是一个实例,各个岗位,但我一直没能找到完美的答案。到目前为止,最好的我遇到的是:

 乌里eventsUri = Uri.parse(内容://com.android.calendar/events);
乌里deleteEventUri = Uri.withAppendedPath(eventsUri,将String.valueOf(ID2));
。DeleteEventActivity.context.getContentResolver()删除(deleteEventUri,NULL,NULL);
 

其中ID2是我要删除的事件的ID。我的问题是,我只是想删除一个定期事件的一个实例,但这种code删除所有事件。有没有办法只删除一个实例?谢谢你。

解决方案

这里是基础知识

找到要删除的实例。 (使用 Instances.query() ) 创建的例外URI 与事件ID 附加。 创建 ContentValues​​ 。把你的实例的 BEGIN 值 ... Events.ORIGINAL_INSTANCE_TIME 。把 STATUS_CANCELED 为 ... Events.STATUS 现在,只有插入(yourURI,yourValues​​),这就是它!

I've been looking through the various posts on how to delete just one instance of a recurring event from my Android 2.3 Phone's calendar, but I haven't been able to find the perfect answer. So far, the best I've come across is :

Uri eventsUri = Uri.parse("content://com.android.calendar/events");
Uri deleteEventUri = Uri.withAppendedPath(eventsUri, String.valueOf(id2));
DeleteEventActivity.context.getContentResolver().delete(deleteEventUri, null, null);

Where id2 is the id of the event I want to delete. The problem I have is that I only want to delete one instance of a recurring event, but this code deletes all occurrences. Is there a way to delete only one instance? Thanks.

解决方案

Here are the basics

Find the instance you want to delete. (using Instances.query()) Create the exception URI with the event ID appended. Create ContentValues. Put your instance's BEGIN value as ...Events.ORIGINAL_INSTANCE_TIME. Put STATUS_CANCELED as ...Events.STATUS Now only insert(yourURI, yourValues) and that's it!