We are adding entries into the Android calendar from within our code. For some reason the calendar seems to have been corrupted in some way.
We can't delete any event at all - even ones not added from within our code. If we try to delete one that was added via our code it crashes.
This is the code we use to insert the event. Note that the text is in Hebrew and we are talking about Android 4.1 and up.
// Select which calendar application to use:
int cal_id = CalendarAppointmentScheduler._calIds[0];
// Use a ContentValues object to hold the details of the calendar event you wish to set:
ContentValues cv = new ContentValues();
cv.put(Events.CALENDAR_ID, cal_id);
cv.put(Events.TITLE, ctx.getString(R.string.add_appointment_to_calendar_title) + " " + ad.doctorName + " (" +
ad.doctorSpecialty + ")");
cv.put(Events.EVENT_LOCATION, ad.address);
cv.put(Events.DTSTART, startTime);
cv.put(Events.DTEND, endTime);
cv.put(Events.ALL_DAY, 0); // true = 1, false = 0
cv.put(Events._ID, ad.diaryRecordIndex);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
cv.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
This is the logcat we get:
11-04 16:22:25.975: E/AndroidRuntime(25027): FATAL EXCEPTION: main
11-04 16:22:25.975: E/AndroidRuntime(25027): java.lang.NumberFormatException: Invalid int: "350511201315411-04 16:22:25.975: E/AndroidRuntime(25027): FATAL EXCEPTION: main
11-04 16:22:25.975: E/AndroidRuntime(25027): java.lang.NumberFormatException: Invalid int: "350511201315451602"
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.invalidInt(Integer.java:138)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parse(Integer.java:378)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parseInt(Integer.java:366)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parseInt(Integer.java:332)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.database.MatrixCursor.getInt(MatrixCursor.java:247)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment.initEventCursor(EventInfoFragment.java:1062)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment.access$700(EventInfoFragment.java:117)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment$QueryHandler.onQueryComplete(EventInfoFragment.java:469)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.AsyncQueryService.handleMessage(AsyncQueryService.java:412)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.os.Looper.loop(Looper.java:137)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.reflect.Method.invoke(Method.java:525)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-04 16:22:25.975: E/AndroidRuntime(25027): at dalvik.system.NativeStart.main(Native Method)
11-04 16:22:39.550: E/AndroidRuntime(25072): FATAL EXCEPTION: main51602"
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.invalidInt(Integer.java:138)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parse(Integer.java:378)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parseInt(Integer.java:366)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.Integer.parseInt(Integer.java:332)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.database.MatrixCursor.getInt(MatrixCursor.java:247)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment.initEventCursor(EventInfoFragment.java:1062)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment.access$700(EventInfoFragment.java:117)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.EventInfoFragment$QueryHandler.onQueryComplete(EventInfoFragment.java:469)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.calendar.AsyncQueryService.handleMessage(AsyncQueryService.java:412)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.os.Looper.loop(Looper.java:137)
11-04 16:22:25.975: E/AndroidRuntime(25027): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 16:22:25.975: E/AndroidRuntime(25027): at java.lang.reflect.Method.invoke(Method.java:525)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-04 16:22:25.975: E/AndroidRuntime(25027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-04 16:22:25.975: E/AndroidRuntime(25027): at dalvik.system.NativeStart.main(Native Method)
11-04 16:22:39.550: E/AndroidRuntime(25072): FATAL EXCEPTION: main