add Alarms to Calendar - Android Android OS

Android examples for Android OS:Calendar Contract

Description

add Alarms to Calendar

Demo Code


//package com.java2s;

import android.content.ContentResolver;
import android.content.ContentValues;

import android.net.Uri;

import android.provider.CalendarContract.Reminders;

public class Main {
    private static void addAlarms(ContentResolver cr, long eventId,
            int minutes, int method) {
        String reminderUriString = "content://com.android.calendar/reminders";
        ContentValues reminderValues = new ContentValues();
        reminderValues.put(Reminders.EVENT_ID, eventId);
        // Default value of the system. Minutes is a integer
        reminderValues.put(Reminders.MINUTES, minutes);
        // Alert Methods: Default(0), Alert(1), Email(2), SMS(3)
        reminderValues.put(Reminders.METHOD, method);

        cr.insert(Uri.parse(reminderUriString), reminderValues);

    }// w  w w.j  a v a 2 s  .  c o  m
}

Related Tutorials