Sunday, June 6, 2010

Working with the Android Calendar

Last December, we wrote an article at about how to use the undocumented Android Calendar content provider. At the time, we'd written the code for Android SDK 1.6. Numerous updates later, this code still worked on Android 2.1. Now, however, Android SDK 2.2 finally broke it. Interestingly, the fixes were rather straight forward, though.

Instead of trying to update the article, write a new one, or try to post all the changes somewhere, we've decided to open source the code so others can see it and, if they'd like, contribute to it. The idea of the code is to demonstrate how to use the calendar content provider. Right now, it shows how to add, edit, and delete a basic entry as well as read the contents. If you'd like to see more, why not contribute to the code so others can see more to?

This uses an undocumented content provider. As it has changed, it may continue to change. The use of this code is at your own risk. Any damage it does is not our fault. You've been warned.

We also don't necessarily recommend this method of controlling a user's calendar. It interfaces with Google Calendars, which has an API of its own that is well documented and can perform everything needed. This avoids any complications with the Android client, will work even if the devices doesn't have a calendar (a non-Google Android device, for instance), and its documented. :)

In any case, we've tested the current code on our Nexus One with Android 2.2 and our Evo 4G with Android 2.1-update1. It works, but it may not work on your devices. Use with care.

No comments: