我正在尝试从我的代码更新我手机上的日历事件,但 context.getContentResolver().update 一直返回 0,当然,当我在日历应用程序中查看它时,没有对事件进行任何更改。
我正在使用 context.getContentResolver().query 获取事件 ID、开始时间等,并且我正在获取 431、4、233 等唯一数字,所以我假设我正在使用的事件 ID 是真实的。
我了解执行此操作的官方方法是通过 Google 的服务器而不是使用 update(),但对于我的实现而言,这样做没有意义(甚至一般来说,但我离题了)。
我是在做错什么,还是在尝试做 Android 根本不允许的事情?
Uri updateEventUri = ContentUris.withAppendedId(Uri.parse("content://com.android.calendar/events"), id);
ContentValues cv = new ContentValues();
begin.set(Calendar.HOUR_OF_DAY, arg0.getCurrentHour()); //begin is a java.util.Calendar object
begin.set(Calendar.MINUTE, arg0.getCurrentMinute());
//cv.put("_id", id);
//cv.put("title", "yeahyeahyeah!");
cv.put("dtstart", begin.getTimeInMillis());
int updatedrowcount = context.getContentResolver().update(updateEventUri, cv, null, null);
System.out.println("updated "+updatedrowcount+" rows with id "+id);
此处发布了一个相关问题,没有回复https://stackoverflow.com/questions/5636350/update-android-calendar-event
如果我能澄清任何事情,请告诉我;我非常感谢你们和洋娃娃能提供的任何意见!