本文介绍了如何删除日历项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现我的第一个Android程序。它应该写的日历条目(我知道,不是最好的任务开始编程的Andorid)。

I'm trying to implement my first android Program. It should write calendar entries (I know, not the best task to begin programming Andorid).

我已经试过:

Uri CALENDAR_URI = Uri.parse("content://calendar/events");
ContentResolver cr = getContentResolver();
cr.delete(CALENDAR_URI, null, null); // Delete all
cr.delete(CALENDAR_URI, "calendar_id=1", null); // Delete all in default calendar
cr.delete(CALENDAR_URI, "_id=1", null); // Delete specific entry

毫无效果。我allays得到一个无法删除的网址。

Nothing worked. I allays get a "cannot delete that URL".

插入日历项很简单:

ContentValues values = new ContentValues();
values.put("calendar_id", 1);
values.put("title", this.title);
values.put("allDay", this.allDay);
values.put("dtstart", this.dtstart.toMillis(false));
values.put("dtend", this.dtend.toMillis(false));
values.put("description", this.description);
values.put("eventLocation", this.eventLocation);
values.put("visibility", this.visibility);
values.put("hasAlarm", this.hasAlarm);

cr.insert(CALENDAR_URI, values);

据我访问日历工作插入方法。

According to my insert method accessing the calendar worked.

谢谢,亚瑟!

推荐答案

确定,有一件事我没有尝试:

OK, one thing I didn't try:

Uri CALENDAR_URI = Uri.parse("content://calendar/events");
int id = 1; // calendar entry ID
Uri uri = ContentUris.withAppendedId(CALENDAR_URI, id);
cr.delete(uri, null, null);

这是我所缺少的:

Uri uri = ContentUris.withAppendedId(CALENDAR_URI, id);

应该导致内容://日历/事件/ 1

should lead to content://calendar/events/1

现在我的日历是空的: - )

Now my Calendar is empty :-)

这篇关于如何删除日历项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 05:52