我正在使用 Google 日历 API。我已通过此代码向事件添加提醒
ContentValues values1 = new ContentValues();
values1.put("event_id", eventId);
values1.put("method", 1);
values1.put( "minutes", reminderValue );
Uri reminder = Uri.parse("content://com.android.calendar/reminders");
this.getContentResolver().insert(reminder, values1);
我的问题是我知道如何添加提醒。我需要查询更新提醒。通过这段代码,它为一个事件添加了多个提醒。
请帮帮我。
谢谢
最佳答案
我认为你不能直接更新已经设置的提醒。首先你应该使用以下代码获取你需要更新的提醒的id:
String[] projection = new String[] {
CalendarContract.Reminders._ID,
CalendarContract.Reminders.METHOD,
CalendarContract.Reminders.MINUTES
};
Cursor cursor = CalendarContract.Reminders.query(
contentResolver, eventId, projection);
while (cursor.moveToNext()) {
long reminderId = cursor.getLong(0);
int method = cursor.getInt(1);
int minutes = cursor.getInt(2);
// etc.
}
cursor.close();
然后使用此 reminderid,您必须使用此代码删除已设置的提醒:
Uri reminderUri = ContentUris.withAppendedId(
CalendarContract.Reminders.CONTENT_URI, reminderId);
int rows = contentResolver.delete(reminderUri, null, null);
然后使用您的代码再次插入提醒。希望这有助于...
关于java - 谷歌日历 API : Updating Reminders to an event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13469066/