Today i came across an article, in that article i found a great thing that the Calendar URI in FROYO 2.2 version is changed from content://calendar/calendars to content://com.android.calendar/calendars.
To manage the compatibility with such Calendar Code across all the version, we need to handle Old URI along with the New URI, we can handle it in following way:
Uri CalendarUri, EventsUri; if (android.os.Build.VERSION.SDK_INT <= 7 ) { CalendarUri = Uri.parse("content://calendar/calendars"); EventsUri = Uri.parse("content://calendar/events"); } else { CalendarUri = Uri.parse("content://com.android.calendar/calendars"); EventsUri = Uri.parse("content://com.android.calendar/events"); }
In above code, android.os.Build.VERSION.SDK_INT will return the SDK version number that you are testing with.
Article’s Actual link: http://pareshmayani.blogspot.com/2010/11/android-working-with-calendar-and_25.html