Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UriMatcher Uri * and # difference

I'm trying to implement my own ContentProvider based on few examples but I'm confused by different approaches in UriMAtcher. For instance: JavaDoc shows it with #like this:

sURIMatcher.addURI("contacts", "people", PEOPLE);
sURIMatcher.addURI("contacts", "people/#", PEOPLE_ID);
sURIMatcher.addURI("contacts", "people/#/phones", PEOPLE_PHONES);
sURIMatcher.addURI("contacts", "people/#/phones/#", PEOPLE_PHONES_ID);

but in "iosched" reference app by Google it uses * like this:

matcher.addURI(authority, "rooms", ROOMS);
matcher.addURI(authority, "rooms/*", ROOMS_ID);
matcher.addURI(authority, "rooms/*/sessions", ROOMS_ID_SESSIONS);

Can anybody explain the difference of these two approaches ?

like image 288
oleg.semen Avatar asked Apr 03 '15 10:04

oleg.semen


1 Answers

Refer official docs : http://developer.android.com/reference/android/content/UriMatcher.html.

public void addURI (String authority, String path, int code)

Added in API level 1 Add a URI to match, and the code to return when this URI is matched. URI nodes may be exact match string, the token "*" that matches any text, or the token "#" that matches only numbers.

like image 111
gaurav jain Avatar answered Nov 09 '22 13:11

gaurav jain