通过我的应用程序更新和删除android中的日历事件

时间:2013-03-05 11:52:23

标签: android events calendar

任何人都可以告诉我如何修改(编辑)和删除用户自己使用我的Android应用程序添加的android日历事件。我已经尝试了很多,但没有一个对我很好。我是第一次处理这些日历。我们有解决方案吗?

1 个答案:

答案 0 :(得分:0)

看看这个问题:StackOverflow

这段代码对我有用。

Uri eventsUri = Uri.parse("content://com.android.calendar/events");
ContentResolver cr = getContentResolver();
Cursor cursor;
cursor = cr.query(eventsUri, new String[]{ "_id" },"calendar_id=" + 1, null, null);
while(cursor.moveToNext()) {
    long eventId = cursor.getLong(cursor.getColumnIndex("_id"));
    cr.delete(ContentUris.withAppendedId(eventsUri, eventId), null, null);
}
cursor.close();
// Show message
Toast.makeText(getApplicationContext(), "Calendar Cleared!",Toast.LENGTH_LONG).show();