我已按照此链接中的教程 –
http://jimblackler.net/blog/?p=151&cpage=2#comment-52767来访问内部的android日历数据库(即使它没有得到SDK的正式支持).它适用于除重复活动之外的所有条目.光标根本不会返回任何重复发生的事件.有人可以帮助我吗?以下是我的光标声明 –
String[] projection = new String[] { "title","description","dtstart","eventLocation" }; String selection = "(calendar_id=" + calID + ")AND " + (now - window) + "<dtstart AND dtstart< " + (now + (window)); String sortorder = "dtstart ASC"; Cursor managedCursor = getCalendarManagedCursor(projection,selection,"events",sortorder); private Cursor getCalendarManagedCursor(String[] projection,String selection,String path,String sort) { Uri calendars = Uri.parse("content://calendar/" + path); Cursor managedCursor = null; try { managedCursor = getContentResolver().query(calendars,projection,null,sort); } catch (IllegalArgumentException e) { Log.w(DEBUG_TAG,"Failed to get provider at [" + calendars.toString() + "]"); } if (managedCursor == null) { // try again calendars = Uri.parse("content://com.android.calendar/" + path); try { managedCursor = getContentResolver().query(calendars,sort); } catch (IllegalArgumentException e) { Log.w(DEBUG_TAG,"Failed to get provider at [" + calendars.toString() + "]"); }`
解决方法
如果需要查找定期事件,请使用Instances表.
查询它的URI是:
> instances / when / * / * – 两次(毫秒)之间的所有实例
> instances / whenbyday / * / * – 两次(天)之间的所有实例
> instances / groupbyday / * / * – 与whenbyday相同,但按开始日分组
该表中的列列表是:
> _id – 此实例的ID
> event_id – 从中创建的事件
>开始 – 开始时间(毫秒)
> end – 结束时间(毫秒)
> startDay – 实例的开始日期
> endDay – 实例结束日
> startMinute – 午夜分钟(0..1440)
> endMinute – 从午夜开始的分钟
您还可以使用“事件”和“日历”表中的列.
您可以在链接的同一页面上看到一个示例:http://jimblackler.net/blog/?p=151
例:
String[] projection = new String[] { "title","begin","eventLocation" }; String selection = "calendar_id = " + calID; String path = "instances/when/" + (now - window) + "/" + (now + window); String sortOrder = "begin DESC"; Cursor managedCursor = getCalendarManagedCursor( projection,path,sortorder);
编辑:谷歌似乎开始记录日历提供商.浏览到Calendar Providier | Google Developers以获取更多信息.