public Uri createTaskEvent( Task task, ContentResolver cr, ContentValues values, boolean deleteEventIfExists) { String eventuri = getTaskEventUri(task); if (!TextUtils.isEmpty(eventuri) && deleteEventIfExists) { deleteTaskEvent(task); } try { Uri uri = getCalendarContentUri(Calendars.CALENDAR_CONTENT_EVENTS); values.put("title", task.getTitle()); values.put("description", task.getNotes()); values.put("hasAlarm", 0); if (preIceCreamSandwich()) { values.put("transparency", 0); values.put("visibility", 0); } boolean valuesContainCalendarId = (values.containsKey(CALENDAR_ID_COLUMN) && !TextUtils.isEmpty(values.getAsString(CALENDAR_ID_COLUMN))); if (!valuesContainCalendarId) { String calendarId = preferences.getDefaultCalendar(); if (!TextUtils.isEmpty(calendarId)) { values.put("calendar_id", calendarId); } } createStartAndEndDate(task, values); Uri eventUri = cr.insert(uri, values); cr.notifyChange(eventUri, null); return eventUri; } catch (Exception e) { // won't work on emulator log.error(e.getMessage(), e); } return null; }