我写了一个获取我的活动的Android应用程序,
如何识别事件(某些唯一ID) 并删除或编辑它?
private void fetchEvents() {
String[] selection = new String[] { "calendar_id", "title", "description",
"dtstart", "dtend", "eventLocation" };
String projection = "description LIKE ?";
String[] selecionArgs = new String[]{"%/images/%"};
String orderby = "dtstart ASC";
Cursor cursor = getContentResolver()
.query(
Uri.parse("content://com.android.calendar/events"),
selection, projection,
selecionArgs, orderby);
cursor.moveToFirst();
// fetching calendars name
String CNames[] = new String[cursor.getCount()];
// fetching calendars id
nameOfEvent.clear();
startDates.clear();
endDates.clear();
descriptions.clear();
for (int i = 0; i < CNames.length; i++) {
nameOfEvent.add(cursor.getString(1));
startDates.add(new Date(Long.parseLong(cursor.getString(3))));
//endDates.add(new Date(Long.parseLong(cursor.getString(4))));
String fullDescription = cursor.getString(2);
int firstIndex = fullDescription.indexOf("localUri: ");
firstIndex = (firstIndex < 0)? 0 : 10;
int lastIndex = fullDescription.indexOf("\n");
lastIndex = (lastIndex < 0)? fullDescription.length() : lastIndex;
descriptions.add(fullDescription.substring(firstIndex, lastIndex));
CNames[i] = cursor.getString(1);
cursor.moveToNext();
}
}