从android中的日历更新/删除重复事件的实例

时间:2014-05-09 05:18:15

标签: android calendar

我想动态地从android中的日历更新/编辑周期性事件的实例。任何一个有想法请帮帮我。

1 个答案:

答案 0 :(得分:0)

尝试下面的代码,我已开发的代码,看看你是否觉得它很有用。

cr = this.getContentResolver();

                if (android.os.Build.VERSION.SDK_INT <= 7) {

                    uri = Uri.parse("content://calendar/events");
                } else {

                    uri = (Events.CONTENT_URI);
                }

                values = new ContentValues();
                values.put(Events.DTSTART, startDateTimeInMillis);
                values.put(Events.DTEND, endDateTimeInMillis);
                values.put(Events.TITLE, txtTitle.getText().toString());
                values.put(Events.DESCRIPTION, edtNotes.getText().toString());
                values.put(Events.CALENDAR_ID, ConstantData.calId);
                values.put(Events.EVENT_LOCATION, edtLocation.getText().toString());
                // values.put(Events.DURATION, "+P1H");
                values.put(Events.ALL_DAY, false);

                values.put(Events.HAS_ALARM, true);

                values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());

                String where = "_id" + " LIKE '" + eventId + "'" + " and " + Events.CALENDAR_ID + "=" + selectedCalendarId;

                int count = cr.update(uri, values, where, null);

                ContentValues reminders = new ContentValues();
                reminders.put(Reminders.EVENT_ID, eventId);
                reminders.put(Reminders.METHOD, Reminders.METHOD_ALERT);
                reminders.put(Reminders.MINUTES, alarmBeforeValue);

                String whereReminder = "event_id" + " LIKE '" + eventId + "'";
                int countReminder = cr.update(Reminders.CONTENT_URI, reminders, whereReminder, null);