Code example for UriMatcher

Methods: addURI, match

0
		return 0; 
	} 
 
	@Override 
	public String getType(Uri taskUri) {
		UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
		matcher.addURI(TaskProvider.AUTHORITY, "task", TASKS);
		matcher.addURI(TaskProvider.AUTHORITY, "task/#", TASK_ID);
		switch (matcher.match(taskUri)) {
		case TASKS:
			return "vnd.android.cursor.dir/Tasks"; 
		case TASK_ID:
			return "vnd.android.cursor.item/Task"; 
		default: 
			throw new IllegalArgumentException("Unknown URI " + taskUri);
		} 
	} 
 
	@Override 
	public Uri insert(Uri tableUri, ContentValues taskContent) {
		Task newTask = new Task(taskContent);