添加活动时。我有这个代码,但我认为我必须把id
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
intent.putExtra("color", mCalendarPrivate.getColor());
startActivity(intent);
如何更新和删除活动? 我希望有人可以帮助我。
答案 0 :(得分:0)
要进行更新,请删除您要 eventId ...
的活动更新:
private int UpdateCalendarEntry(int entryID) {
int iNumRowsUpdated = 0;
ContentValues event = new ContentValues();
event.put("title", "Changed Event Title");
event.put("hasAlarm", 1); // 0 for false, 1 for true
Uri eventsUri = Uri.parse(getCalendarUriBase()+"events");
Uri eventUri = ContentUris.withAppendedId(eventsUri, entryID);
iNumRowsUpdated = getContentResolver().update(eventUri, event, null,
null);
Log.i(DEBUG_TAG, "Updated " + iNumRowsUpdated + " calendar entry.");
return iNumRowsUpdated;
}
删除:
private int DeleteCalendarEntry(int entryID) {
int iNumRowsDeleted = 0;
Uri eventsUri = Uri.parse(getCalendarUriBase()+"events");
Uri eventUri = ContentUris.withAppendedId(eventsUri, entryID);
iNumRowsDeleted = getContentResolver().delete(eventUri, null, null);
Log.i(DEBUG_TAG, "Deleted " + iNumRowsDeleted + " calendar entry.");
return iNumRowsDeleted;
}