Reputation: 21076
I have two Uris. Suppose they are:
content://myprovider/messages
content://myprovider/messages/#
In my extended ContentProvider I have declared the following:
private static final int MESSAGES = 1;
private static final int MESSAGES_ID = 2;
private static final UriMatcher sUriMatcher;
static {
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sUriMatcher.addURI("myprovider", "messages", MESSAGES);
sUriMatcher.addURI("myprovider", "messages/#", MESSAGES_ID);
}
When I use the...
content://myprovider/messages/#
...Uri when calling any ContentProvider method, say insert, and my ContentProvider method does a...
sUriMatcher.match(uri)
...and I get back 1 (MESSAGES).
Why???
Upvotes: 1
Views: 432
Reputation: 26
If you want to get MESSAGES_ID
, the uri has to be written like content://myprovider/messages/12345
or you have to add a pattern for MESSAGES_ID
like:
sUriMatcher.addURI("myprovider", "messages/*", MESSAGES_ID);
Upvotes: 1