我已按照此链接中的教程 - http://jimblackler.net/blog/?p=151&cpage=2#comment-52767访问内部安卓日历数据库(即使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,
selection, 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,
projection, selection, null, sort);
} catch (IllegalArgumentException e) {
Log.w(DEBUG_TAG,
"Failed to get provider at [" + calendars.toString()
+ "]");
}`
Run Code Online (Sandbox Code Playgroud)
Mar*_*rot 16
Instances如果需要查找重复发生的事件,请使用该表.
查询它的URI是:
instances/when/*/* - 两次(毫秒)之间的所有实例instances/whenbyday/*/* - 两次(天)之间的所有实例instances/groupbyday/*/*- 相同whenbyday,但按开始日分组该表中的列列表是:
_id - 此实例的IDevent_id - 它是从它创建的事件begin - 开始时间(毫秒)end - 结束时间(毫秒)startDay - 实例的开始日期endDay - 实例结束日startMinute - 午夜(0..1440)endMinute - 从午夜开始的几分钟您还可以使用Events和Calendar表中的列.
您可以在链接的同一页面上看到一个示例:http://jimblackler.net/blog/?p = 151
例:
String[] projection = new String[] {
"title", "description", "begin", "eventLocation"
};
String selection = "calendar_id = " + calID;
String path = "instances/when/" + (now - window) + "/" + (now + window);
String sortOrder = "begin DESC";
Cursor managedCursor = getCalendarManagedCursor(
projection, selection, path, sortorder);
Run Code Online (Sandbox Code Playgroud)
编辑:谷歌似乎开始记录日历提供商.浏览到日历Providier | Google Developers了解更多信息.
| 归档时间: |
|
| 查看次数: |
7047 次 |
| 最近记录: |