I am writing a content provider and I'm trying to match URIs using UriMatcher. I've already written a few matchers ending either in a ...path/
or .../path/#
and that works well.
However, my next step is to start using URIs that include arguments in the query - i.e. .../path/#?arg1=val1,arg2=val2
, etc. How do I match the URI against that? According to the addURI() documentation, it only accepts "*" and "#" as wildcards, for any text or numbers, respectively. How do I match against a particular pattern of arguments? Or am I supposed to only match the static part of the URI, and then parse the arguments in the query() method in my content provider?
The reason I'd rather match than parse is because the number of arguments supplied in a valid query can change - i.e. '.../path?arg1=val1is a valid query, and so is '.../path?arg1=val1,arg2=val2
. I'd rather not have to write "if arg1 exists, then , if arg1 and arg2 exists, then , etc etc" in my content provider's query function. It can get complex quickly, and it seems a URI matcher would help simplify the code a lot.