Hi All,
 I am trying to remove all Calendar related entries from a phone(Galaxy tab)
Here is the code

/**
         * Deletes all calendar info
         */
        private boolean _deleteCalendarInfo() {
                try {

                        String uriPrefix;
                        if (Build.VERSION.SDK_INT <= 
Build.VERSION_CODES.ECLAIR_MR1) {
                                uriPrefix = "content://calendar/";
                        } else {
                                uriPrefix = "content://com.android.calendar/";
                        }

                        int cnt = contentResolver.delete(Uri.parse(uriPrefix + 
"events"),
null, null);
                        Log.i("Data Wipe","Calendar events deleted Count "+cnt);
                        contentResolver.delete(Uri.parse(uriPrefix + 
"calendars"), null,
                                        null);
                        Log.i("Data Wipe","Calendars events deleted Count 
"+cnt);
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        Log.i("Data Wipe","Calendar delete 
failed"+e.toString());
                        return false;
                }
                return true;
        }


The code executes successfully, but after that when i go into calendar
manually and try to add an event, it is giving force close with
following error
"android.database.CursorIndexOutOfBoundsException: Index 0 requested,
with a size of 0"

Detailed stack trace:-

05-02 14:02:08.077: ERROR/AndroidRuntime(3412): Caused by:
android.database.CursorIndexOutOfBoundsException: Index 0 requested,
with a size of 0
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:84)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.database.CursorWrapper.getInt(CursorWrapper.java:123)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
com.android.calendar.EditEvent.setCalendarData(EditEvent.java:4098)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
com.android.calendar.EditEvent.onCreate(EditEvent.java:2333)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-02 14:02:08.077: ERROR/AndroidRuntime(3412):     ... 11 more



I have probably found  what the problem is on Stack Overflow.It states
"Query is returning 0 rows, which is why you are getting an error
attempting to use the 1st row of a 0-row Cursor"

Is there any better way to Delete all calendar info ?
Thanks,
Alok

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to