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

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

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