CalendarContract.Instances.query() searchQuery
Asked Answered
I

0

6

I'm trying to determine whether a given event exists in the user's calendar, where equality is determined by start time, end time, title, and location all matching.

The documentation says:

public static final Cursor query (ContentResolver cr, String[] projection, long begin, long end, String searchQuery)

where searchQuery is:

searchQuery A string of space separated search terms. Segments enclosed by double quotes will be treated as a single term.

My code roughly something like this:

long startTime = eventStartTime;
long endTime = eventEndTime;

public static final String[] EVENT_INSTANCE_PROJECTION = new String[] {
    Instances._ID,
    Instances.BEGIN,
    Instances.END,
    Instances.EVENT_ID,
    Instances.TITLE,
    Instances.EVENT_LOCATION
};

Cursor cursor = Instances.query(activity.getContentResolver(), EVENT_INSTANCE_PROJECTION, startTime, endTime, queryString);

Without the queryString, this returns the events in that time slot. What is queryString supposed to be? In particular, how might one use this call to only return events in that time frame with a given title, i.e. WHERE Instances.TITLE='EventTitle'. Or is this even the right call to use to do that? I'm confused by the format this command is expecting.

EDIT

It looks like the query is just appending to the path, so an example would be:

content://com.android.calendar/instances/search/1402678800000/1402704000000/

Where the numbers are the start date and end date in milliseconds.

Incorrigible answered 29/4, 2014 at 18:33 Comment(1)
Wow, over 2 years since I asked this question and the documentation around it hasn't improved at all...Incorrigible

© 2022 - 2024 — McMap. All rights reserved.