title: Creating a Calendar Event on Specific Dates in Android?
body: <p>I have a specific requirement to create a Calendar Event that will occur on specific dates. It is not the scenario it will occur Weekly, monthly, yearly but it may come for 13 days, 14 days, 15 days etc. I have on which dates it will occur but was failing to set the recurring dates. below is my code</p>
  
  <pre><code>ContentValues calEvent = new ContentValues();
              calEvent.put(CalendarContract.Events.CALENDAR_ID, 1);
              calEvent.put(CalendarContract.Events.TITLE, title);
              calEvent.put(CalendarContract.Events.DTSTART, d.getTime());
              calEvent.put(CalendarContract.Events.DTEND, d.getTime()
                      + (2 * 60 * 60 * 1000));
              calEvent.put(CalendarContract.Events.HAS_ALARM, 1);
              calEvent.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone
                      .getDefault().getID());
              calEvent.put(CalendarContract.Events.EVENT_LOCATION, location);
              calEvent.put(CalendarContract.Events.DESCRIPTION, description);
              calEvent.put(CalendarContract.Events.RDATE, sdf1.format(d)
                      + "T033000Z");
              // calEvent.put(CalendarContract.Reminders.RRULE, value);
              Uri uri = contentResolver.insert(
                      CalendarContract.Events.CONTENT_URI, calEvent);
  
              // The returned Uri contains the content-retriever URI for the
              // newly-inserted event, including its id
              int id = Integer.parseInt(uri.getLastPathSegment());
              // Toast.makeText(ctx, "Created Calendar Event " + id,
              // Toast.LENGTH_SHORT).show();
              eventId = eventId + (eventId.equalsIgnoreCase("") ? id : "," + id);
              ContentValues calReminder = new ContentValues();
  
              calReminder.put(CalendarContract.Reminders.MINUTES, minutes);
              calReminder.put(CalendarContract.Reminders.EVENT_ID, id);
              // calReminder.put(CalendarContract.Reminders.HAS_ALARM, 1);
              calReminder.put(Reminders.METHOD, Reminders.METHOD_ALERT);
              Uri uri1 = contentResolver.insert(
                      CalendarContract.Reminders.CONTENT_URI, calReminder);
  
              // The returned Uri contains the content-retriever URI for the
              // newly-inserted event, including its id
              int id1 = Integer.parseInt(uri1.getLastPathSegment());
              // Toast.makeText(ctx, "Created Calendar Reminder " + id1,
              // Toast.LENGTH_SHORT).show();
              reminderId = reminderId
                      + (reminderId.equalsIgnoreCase("") ? id1 : "," + id1);
  </code></pre>
  
  <p>When I use the RDATE with comma separated values of dates as there is startdate &amp; enddate provided, Event is created to all dates between startdate &amp; enddate. </p>