RedDeath
RedDeath

Reputation: 322

Allow user to delete event inserted programmatically android

I have this method to add calendar events programmatically:

@SuppressLint("NewApi") private void Insert event (){
    long calID = 3;
    long startMillis = 0; 
    long endMillis = 0;     
    Calendar beginTime = Calendar.getInstance();
    beginTime.set(2014, 5, 10, 12, 00);
    startMillis = beginTime.getTimeInMillis();
    Calendar endTime = Calendar.getInstance();
    endTime.set(2014, 5, 10, 13, 00);
    endMillis = endTime.getTimeInMillis();

    ContentResolver cr = getContentResolver();
    ContentValues values = new ContentValues();
    values.put(Events.DTSTART, startMillis);
    values.put(Events.DTEND, endMillis);
    values.put(Events.ALL_DAY, true);
    values.put(Events.TITLE, "Title");
    values.put(Events.DESCRIPTION, "Description");
    values.put(Events.CALENDAR_ID, calID);
    values.put(Events.EVENT_LOCATION, "MyLocation");
    values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles"); //Montevideo
    values.put(Events.GUESTS_CAN_MODIFY, true);
    Uri uri = cr.insert(Events.CONTENT_URI, values);        
}

But if I enter to the Calendar application, I can't delete the event. What do I have to change from the event value to let the user delete the events?

Upvotes: 0

Views: 481

Answers (1)

RedDeath
RedDeath

Reputation: 322

The problem was the next line

long calID = 3;

That calendar id is from a calendar that don´t let me delete events (is a sync calendar from hotmail). Just had to change that line to:

long calID = 1;

And that´s it

Upvotes: 1

Related Questions