Delete calendar entries

前端 未结 2 1434
既然无缘
既然无缘 2020-12-10 07:27

I wrote simple code for deleting all entries from android calendar,but it didn\'t delete nothing.

Source code:

public void DeleteEvent(View view){

          


        
2条回答
  •  情深已故
    2020-12-10 08:08

    use this code its right

            public void DeleteEvent(int your_event_id){
    
            int iNumRowsDeleted = 0;
            Uri eventsUri = Uri.parse("content://com.android.calendar/events");
            Cursor cur = getContentResolver().query(eventsUri, null, null, null, null);
    
            while (cur.moveToNext()){
    
                 Uri eventUri = ContentUris.withAppendedId(eventsUri, your_event_id);
                iNumRowsDeleted = getContentResolver().delete(eventUri, null, null);
            }
        }
    

提交回复
热议问题