2

I want to add a recurring event in the calendar programatically., i.e directly without using intent. I user the following ::

ContentResolver cr = cordova.getActivity().getContentResolver();
      ContentValues values = new ContentValues();

      values.put(Events.DTSTART, calendarStart.getTimeInMillis());
      values.put(Events.DTEND, calendarEnd.getTimeInMillis());
      values.put(Events.TITLE, title);
      values.put(Events.CALENDAR_ID, 1);
      values.put("rrule", "FREQ=DAILY"); //For recurring event
      values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());

      Uri uri = cr.insert(eventsUri, values);

The event is only added for 2 weeks . I want it to be added for atleast 2 years or more.., can be forever also. I have used the Combinations UNTIL also,, but nothing works. Wat should I update the code with.. Any help.. Thanks

Bhavna
  • 836
  • 2
  • 6
  • 19

2 Answers2

2

try this, add

values.put(Events.DURATION, "P0600S");

Remove

values.put(Events.DTEND, calendarEnd.getTimeInMillis());
CJ Ramki
  • 2,620
  • 3
  • 25
  • 47
  • For adding a recurring event the DTEND should be removed and duration part must be added.. Finally this worked,.. Thank u :) – Bhavna Nov 27 '13 at 10:26
  • have a look at this issue: http://stackoverflow.com/questions/28871921/add-weekly-event-to-calendar – Sun Jul 01 '15 at 12:40
1

I believe this should be like

values.put(Events.RRULE, "FREQ=YEARLY;INTERVAL=2");

This will make the event for every 2 years.

You can tweak the INTERVAL as you need it.

More more options on this refer http://www.kanzaki.com/docs/ical/rrule.html

Purus
  • 5,701
  • 9
  • 50
  • 89