How to Delete Single Calendar Event

Overview

This article explains how to delete an existing event in Calendar using Tizen platform device API's. This article applies only for systems based on Tizen platform.

Pre-conditions

To use the Calendar API methods, you must declare the necessary features in the config.xml file.

For this example, Open the config.xml file then choose the "Feature" tab and add below features to use the Calendar APIs in your applications.

Delete a Single Calendar Event

You can enable your application to delete an existing calendar item using the remove() method. This method takes "event id" as a parameter.

To delete an existing event you need to follow the below steps:

  • Retrieve the calendar instance.
  • Retrieve calendar event(s).
  • Identify the event to be deleted.
  • Deleted the event.

The default calendar instance is retrieved using the getDefaultCalendar() method.

var myCalendar = null;
// Get the default calendar
myCalendar = tizen.calendar.getDefaultCalendar("EVENT");

To fetch complete or partial (based on filters) list of events in default calendar, call find() method. In this example onEventSearchSuccess() method is registered as a success callback and onError() method is registered to handle errors.

//The error callback
function onError(e) {
    console.log(e.message);
}

// Fetch all events in default calendar
myCalendar.find(onEventSearchSuccess, onError);

In this example, all the events are retrieved because no filter is used in the find() method. The first event is removed using the remove() method.

// Define the event success callback.
function onEventSearchSuccess(events) {
    // Here we are deleting the first calendar event.
    myCalendar.remove(events[0]);
    console.log("First item deleted.");
}
You can specify the filter criteria using a filter, and a sorting order for the search operation through the filter and sortMode parameter of the find() method.