長現在= System.currentTimeMillis的();
Uri.Builder eventsUriBuilder = CalendarContract.Instances.CONTENT_URI.buildUpon();
ContentUris.appendId(eventsUriBuilder, Long.MIN_VALUE);
ContentUris.appendId(eventsUriBuilder, Long.MAX_VALUE);
String[] projection = new String[]{CalendarContract.Instances.CALENDAR_ID, CalendarContract.Instances.TITLE,
CalendarContract.Instances.DESCRIPTION, CalendarContract.Instances.BEGIN,
CalendarContract.Instances.END, CalendarContract.Instances.EVENT_LOCATION,
CalendarContract.Instances.EVENT_ID};
Uri eventsUri = eventsUriBuilder.build();
Cursor instance_cursor = getActivity().getContentResolver().query(
eventsUri, projection, CalendarContract.Instances.BEGIN + " >= " + now + " and " + CalendarContract.Instances.BEGIN
+ " <= " + (now + 2592000000L) + " and " + CalendarContract.Instances.VISIBLE + " = 1",
null, CalendarContract.Instances.DTSTART + " ASC");
感謝威廉。工作得很好。 –