我的应用程序允许用户使用CalendarContract.Events API查看和更改日历事件.代码执行Events表的更新,然后使用Instances表将其读回(稍后).例如,对Title的更改工作正常(即,我更新事件并可以回读实例中的更改).对Events.DTEND的更改确实显示在Instances.DTEND中,但是如何让该更新也显示在Instances.END中?
这很重要,因为很明显,Android日历应用程序(以及我的应用程序)也使用Instances.BEGIN和Instances.END来确定要在日历中显示的内容.
这是我的更新代码:
ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put (Events.CALENDAR_ID,calendarID); values.put (Events.Title,Title); values.put (Events.DTEND,eventEnd.getTimeInMillis()); String where = "_ID =" + eventID + " and " + CALENDAR_ID + "=" + calendarID; int count = cr.update (Events.CONTENT_URI,values,where,null); if (count != 1) throw new IllegalStateException ("more than one row updated");
谢谢.
解决方法 解决方案原来是添加开始日期:ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put (Events.CALENDAR_ID,Title); values.put (Events.DTSTART,eventStart.getTimeInMillis()); values.put (Events.DTEND,null); if (count != 1) throw new IllegalStateException ("more than one row updated");
需要注意的是:此案例仅说明如何更新非重复事件.非重复事件具有空RRulE.
我怀疑提供者代码正在做的是仅使用您提供的值而不是重新获取开始日期本身(显然,如果用户更改了开始日期,您无论如何都必须提供它).从减少数据库访问的角度来看,这是有道理的.太糟糕的谷歌没有记录任何这些.
总结以上是内存溢出为你收集整理的android – 通过events.dtend更新日历instances.end全部内容,希望文章能够帮你解决android – 通过events.dtend更新日历instances.end所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)