Calendar event problem
<p>Actually i am get stuck in a big problem..I have created an app from which i can save event in my device calendar..Now when i save new events from my app in my device calendar it will always delete the events save previously by my app and save a new event and so on..so all works fine..now the big problem is that while deleting it will delete all the events of the calendar that are present in the device calendar including the events that are save by my app..so what i want is to delete only that event that are put by my app while inserting new event from my app not that are already present or which are directly assigned by me in device calendar..so can anyone please help me out to resolve this problem..the code i have use for inserting and deleting are..</p>

<pre><code>    Resources res = c.getResources();

    Uri EVENTS_URI = Uri.parse("content://com.android.calendar/" + "events");

    Uri REMINDERS_URI = Uri.parse("content://com.android.calendar/" + "reminders");

    ContentResolver cr = c.getContentResolver();

    Uri uri= ContentUris.withAppendedId(EVENTS_URI, 1);
    deleteEvent(cr, Resources res = c.getResources();

    Uri EVENTS_URI = Uri.parse("content://com.android.calendar/" + "events");

    Uri REMINDERS_URI = Uri.parse("content://com.android.calendar/" + "reminders");

    ContentResolver cr = c.getContentResolver();

    //Deleting event from device calendar before saving new event
    deleteEvent(cr, EVENTS_URI, 1);

     //saving new data to calendar
    ContentValues values = new ContentValues();
    values.put("calendar_id", 1);
    values.put("title", str);
    values.put("description", m_strDescription);                    
    values.put("dtstart", cal.getTimeInMillis()); 
    values.put("dtend", cal.getTimeInMillis()); 
    values.put("hasAlarm", 1);
        Uri event = cr.insert(EVENTS_URI, values);

    values = new ContentValues();
    values.put("event_id", Long.parseLong(event.getLastPathSegment()));
    values.put("method", 1);
    values.put("minutes", 10);
    cr.insert(REMINDERS_URI, values);
</code></pre>

<p><strong>Functions for deleting event</strong></p>

<pre><code>private void deleteEvent(ContentResolver resolver, Uri eventsUri, int calendarId) 
{
    Cursor cursor;
    if (android.os.Build.VERSION.SDK_INT &lt;= 7) 
    { 
        cursor = resolver.query(eventsUri, new String[]{ "_id" }, "Calendars_id=" + calendarId, null, null);
    } 
    else 
    { 
        cursor = resolver.query(eventsUri, new String[]{ "_id" }, "calendar_id=" + calendarId, null, null);
    }
    while(cursor.moveToNext()) 
    {
        long eventId = cursor.getLong(cursor.getColumnIndex("_id"));
        resolver.delete(ContentUris.withAppendedId(eventsUri, eventId), null, null);
    }
    cursor.close();
}
</code></pre>
