You can use the next method:

<pre style="background-image: URL(; background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> public static void add(Activity activity, String title, String description, Calendar initDate, Calendar finalDate) {
final String baseUriCalendar = getCalendarUriBase();
final Uri EVENTS_URI = Uri.parse(baseUriCalendar + "//events");
final ContentResolver cr = activity.getContentResolver();
// event insert
ContentValues values = new ContentValues();
values.put("calendar_id", 1);values.put("title", title);
values.put("allDay", 0);
values.put("dtstart", initDate.getTimeInMillis());
values.put("dtend", finalDate.getTimeInMillis());
values.put("description", description);values.put("visibility", 0);
values.put("hasAlarm", 1);
final Uri event = cr.insert(EVENTS_URI, values);// reminder insert
final Uri REMINDERS_URI = Uri.parse(baseUriCalendar + "//reminders");
values = new ContentValues();
values.put("event_id", Long.parseLong(event.getLastPathSegment()));
values.put("method", 1);
values.put("minutes", 10);
cr.insert(REMINDERS_URI, values);

Blog Logo

Daniel Gomez Rico




The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview