Delete event from Calendar - Android Android OS

Android examples for Android OS:Calendar Event

Description

Delete event from Calendar

Demo Code


import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Attendees;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Reminders;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;

public class Main{
    /**/*from   w  ww.java2  s. c o  m*/
     * Delete event
     */
    public static int deleteEvent(CalendarRequest crx) throws Exception {
        ContentResolver cr = crx.getContext().getContentResolver();
        Uri deleteUri = ContentUris.withAppendedId(
                CalendarContract.Events.CONTENT_URI, crx.getEventID());
        int y = cr.delete(deleteUri, null, null);
        return y;
    }
}

Related Tutorials