从我的Andr​​oid日历中删除定期事件的一个实例 [英] Delete only one instance of a recurring event from my Android calendar

查看:175
本文介绍了从我的Andr​​oid日历中删除定期事件的一个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过关于如何从我的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删除所有事件。有没有办法只删除一个实例?谢谢你。

解决方案

这里是基础知识

  1. 找到要删除的实例。 (使用<一个href="http://developer.android.com/reference/android/provider/CalendarContract.Instances.html#query(android.content.ContentResolver,%20java.lang.String[],%20long,%20long)"相对=nofollow> Instances.query()
  2. 创建的<一个href="http://developer.android.com/reference/android/provider/CalendarContract.Events.html#CONTENT_EXCEPTION_URI"相对=nofollow>例外URI 与事件ID <一href="http://developer.android.com/reference/android/content/ContentUris.html#withAppendedId(android.net.Uri,%20long)"相对=nofollow>附加。
  3. 创建 ContentValues​​ 。把你的实例的 BEGIN 值<一个href="http://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#ORIGINAL_INSTANCE_TIME"相对=nofollow> ... Events.ORIGINAL_INSTANCE_TIME 。把<一href="http://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#STATUS_CANCELED"相对=nofollow> STATUS_CANCELED 为<一个href="http://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#STATUS"相对=nofollow> ... Events.STATUS
  4. 现在,只有<一href="http://developer.android.com/reference/android/content/ContentResolver.html#insert(android.net.Uri,%20android.content.ContentValues)"相对=nofollow>插入(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

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

这篇关于从我的Andr​​oid日历中删除定期事件的一个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆