Is it possible to query CalendarContract.Instances with a custom where clause?
The normal syntax for using this URI is:
Uri.Builder builder = CalendarContract.Instances.CONTENT_URI.buildUpon();
ContentUris.appendId (builder, startDate);
ContentUris.appendId (builder, endDate);
But I want to manipulate the start date comparison by providing my own where clause and omitting the start and stop times from the URI. For sake of a simple example, like this ("projection" defined elsewhere):
final Uri uri = CalendarContract.Instances.CONTENT_URI;
String selection = Instances.BEGIN + " >= " + startTime + " and " +
Instances.END + " <= " + endTime;
Cursor cursor = context.getContentResolver().query (
uri,
projection,
selection,
null,
null);
This is resulting in a DatabaseUtils exception:
03-16 09:57:06.041 W/System.err: java.lang.IllegalArgumentException: Unknown URL content://com.android.calendar/instances/when
03-16 09:57:06.041 W/System.err: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
My real code is more complicated. I need the custom where clause so that I can adjust the start time of all day events, which are stored in UTC time rather than local time. Without an adjustment, the comparison of all day events fails in the where clause and in sorting.
Is there a different URI that I can use with Instances to do what I want?