I have working in android calender. i have add event in Calender programmatically using android app. I have Also Refer this links :IllegalArgumentException: Unknown URL content://com.android.calendar/events when inserting an event to the calendar on Android Adding events to native calendar is not working but is not working in my code .
my Code is:
ContentValues contentEvent = new ContentValues();
// Particular Calendar in which we need to add Event
contentEvent.put("calendar_id", AlarmId);
// Title/Caption of the Event
contentEvent.put("title", "Wedding");
// Description of the Event
contentEvent.put("description", "Wedding Party");
// Venue/Location of the Event
contentEvent.put("eventLocation", "New York");
// Start Date of the Event with Time
contentEvent.put("dtstart", l);
// End Date of the Event with Time
contentEvent.put("dtend", l+60*1000);
// All Day Event
contentEvent.put("allDay", 1);
// Set alarm for this Event
contentEvent.put("hasAlarm",1);
contentEvent.put("eventTimezone", android.text.format.Time.getCurrentTimezone());
Uri eventsUri = getCalendarURI(false);
// event is added successfully
getContentResolver().insert(eventsUri, contentEvent);
// Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
public Uri getCalendarURI(boolean eventUri) {
Uri calendarURI = null;
if (android.os.Build.VERSION.SDK_INT <= 7) {
calendarURI = (eventUri) ? Uri.parse("content://calendar/events")
: Uri.parse("content://calendar/calendars");
} else {
calendarURI = (eventUri) ? Uri
.parse("content://com.android.calendar/events") : Uri
.parse("content://com.android.calendar/calendars");
}
return calendarURI;
}
My issue Is: When i have run my application that time this error have been generated. so how can i solve this error ?
error is:
java.lang.IllegalArgumentException: Unknown URL content://com.android.calendar/
thank you in Advance