请我收到这个我不明白的错误。
这是代码:
Cursor cursor = context.getContentResolver()
.query(Uri.parse("content://com.android.calendar/events"),
new String[] { "calendar_id", "title", "description",
"dtstart", "dtend", "eventLocation","allDay" }, null,
null, null);
cursor.moveToFirst();
// fetching calendars name
String CNames[] = new String[cursor.getCount()];
for (int i = 0; i < CNames.length; i++) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
String day =df.format(cursor.getString(3));
这是 LogCat:
08-30 10:07:09.560: E/AndroidRuntime(5008): FATAL EXCEPTION: main
08-30 10:07:09.560: E/AndroidRuntime(5008): java.lang.IllegalArgumentException: Bad class: class java.lang.String
08-30 10:07:09.560: E/AndroidRuntime(5008): at java.text.DateFormat.format(DateFormat.java:296)
08-30 10:07:09.560: E/AndroidRuntime(5008): at java.text.Format.format(Format.java:93)
08-30 10:07:09.560: E/AndroidRuntime(5008): at com.examples.android.calendar.Utility.readCalendarEvent(Utility.java:46)
08-30 10:07:09.560: E/AndroidRuntime(5008): at com.examples.android.calendar.CalendarView$1.run(CalendarView.java:185)
08-30 10:07:09.560: E/AndroidRuntime(5008): at android.os.Handler.handleCallback(Handler.java:730)
08-30 10:07:09.560: E/AndroidRuntime(5008): at android.os.Handler.dispatchMessage(Handler.java:92)
08-30 10:07:09.560: E/AndroidRuntime(5008): at android.os.Looper.loop(Looper.java:137)
08-30 10:07:09.560: E/AndroidRuntime(5008): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-30 10:07:09.560: E/AndroidRuntime(5008): at java.lang.reflect.Method.invokeNative(Native Method)
08-30 10:07:09.560: E/AndroidRuntime(5008): at java.lang.reflect.Method.invoke(Method.java:525)
08-30 10:07:09.560: E/AndroidRuntime(5008): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-30 10:07:09.560: E/AndroidRuntime(5008): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-30 10:07:09.560: E/AndroidRuntime(5008): at dalvik.system.NativeStart.main(Native Method)