如何更新和删除的Android的日历事件? [英] How to update and remove calendar event in android?
本文介绍了如何更新和删除的Android的日历事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您添加事件。我有这个code,但我认为我必须把标识
When you add event. I have this code but I think that I must put id
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
intent.putExtra("color", mCalendarPrivate.getColor());
startActivity(intent);
我如何更新和删除事件?
我希望有人能帮助我。
How Can I update and remove events? I hope that somebody can help me.
推荐答案
有关更新一个删除一个事件你有 EVENTID ...
For update a remove an event you to have eventId ...
更新:
private int UpdateCalendarEntry(int entryID) {
int iNumRowsUpdated = 0;
ContentValues event = new ContentValues();
event.put("title", "Changed Event Title");
event.put("hasAlarm", 1); // 0 for false, 1 for true
Uri eventsUri = Uri.parse(getCalendarUriBase()+"events");
Uri eventUri = ContentUris.withAppendedId(eventsUri, entryID);
iNumRowsUpdated = getContentResolver().update(eventUri, event, null,
null);
Log.i(DEBUG_TAG, "Updated " + iNumRowsUpdated + " calendar entry.");
return iNumRowsUpdated;
}
删除:
private int DeleteCalendarEntry(int entryID) {
int iNumRowsDeleted = 0;
Uri eventsUri = Uri.parse(getCalendarUriBase()+"events");
Uri eventUri = ContentUris.withAppendedId(eventsUri, entryID);
iNumRowsDeleted = getContentResolver().delete(eventUri, null, null);
Log.i(DEBUG_TAG, "Deleted " + iNumRowsDeleted + " calendar entry.");
return iNumRowsDeleted;
}
这篇关于如何更新和删除的Android的日历事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文