It's especially problematic if you're trying to work with closed
source, such as Android 3.0 - you should consider setting
maxSdkVersion to prevent people from seeing your app on 3.0.

On 2 Maj, 15:34, Dianne Hackborn <[email protected]> wrote:
> You can expect individual devices to behave differently when you are using
> private APIs like these, regardless of platform version.  Writing code like
> this is going to be a continual source of trouble for you.
>
>
>
> On Mon, May 2, 2011 at 4:36 AM, Alok Kulkarni <[email protected]> wrote:
> > 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
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
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