Android – Working With Calendar and Managing Compatibility With Froyo

By -

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

Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...