The code i’m working on lists the events from the calendar, i need to limit the range of dates, and in the examples i see this code:
// Construct the query with the desired date range.
Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, startMillis);
ContentUris.appendId(builder, endMillis);
I don’t understand why appendId is used in this way. startMillis and endMillis are not ids, i would expect that the parameter name had to be provided eg “startdate” , It’s not clear to me why this works, and what other parameters could be specified this way. Are there more parameters supported by appenedId? How can i know?
What appendId actually does is add a
/#to your uri where # is a number. In your example (assumingstartMillis = 1000andendMillis = 3000and the uricontent://com.google.calendar/) this would mean your uri could end up like this:This is something that a uri parser can pickup:
Long story short: appendId is just a convenient and type-safe way to add an integer to your uri path.