Hi,

Please take a look at the 4th bullet in
http://developer.android.com/guide/topics/providers/calendar-provider.html#add-event

What do you mean by it doesn't work?
What do you see in the logcat?
Did you get an exception? If so, please share.
What did resolver.insert() return? If the insert was successful,
resolver.insert() should return a uri to the event. If you get a uri
but can't find the event in the Calendar app, double check the dtstart
i.e. put it in a Time object, print it out and verify.

For fortnightly, the rrule is FREQ=DAILY;INTERVAL=2
To learn more about rrules, read
http://tools.ietf.org/html/rfc5545#section-3.8.5.3. If you don't want
to bother, just add an event using the web or another app then query
the rrule of that event and see what you get.

Don't hard code calendar_id to 1. Let the user pick a calendar.

Thanks,
Mike

On Sun, Apr 22, 2012 at 2:06 AM, Deepak <deepakvs...@gmail.com> wrote:
> I'm trying to add event to the calendar programatically in Android API
> 11. It does not seem to be working, I've pasted the code, also didn't
> find anything on adding fortnightly events. Please if anyone can tell
> what is the issue in the code below.
>        ContentValues event = new ContentValues();
>                event.put("calendar_id", 1);
>                event.put("title", title);
>                event.put("description", description);
>                event.put("eventLocation", location);
>                event.put("dtstart", startDate);
>                switch (recurrance) {
>                case DAILY:
>                        event.put("rrule", "FREQ=DAILY");
>                        break;
>                case MONTHLY:
>                        event.put("rrule", "FREQ=MONTHLY");
>                        break;
>                case WEEKLY:
>                        event.put("rrule", "FREQ=WEEKLY");
>                        break;
>                case FORTNIGHTLY:
>                        event.put("rrule", "FREQ=YEARLY"); //CODE for 
> Fortnight to be
> added.
>                        break;
>                }
>                event.put("dtend", endDate);
>                if (Integer.parseInt(Build.VERSION.SDK) >= 8) {
>                        Uri eventsUri = 
> Uri.parse("content://com.android.calendar/events");
>                        resolver.insert(eventsUri, event);
>                } else {
>                        Uri eventsUri = Uri.parse("content://calendar/events");
>                        resolver.insert(eventsUri, event);
>                }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to