Code example for UriMatcher

Methods: addURImatch

     * Build and return a {@link UriMatcher} that catches all {@link Uri} 
     * variations supported by this {@link ContentProvider}. 
    private static UriMatcher buildUriMatcher() {
        final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
        final String authority = DroidHDContract.CONTENT_AUTHORITY;
        matcher.addURI(authority, "clientes", CLIENTES);
        matcher.addURI(authority, "clientes/search/*", CLIENTES_SEARCH);
        matcher.addURI(authority, "clientes/*", CLIENTES_ID);
        matcher.addURI(authority, "search_suggest_query", SEARCH_SUGGEST);
        return matcher;
    public boolean onCreate() { 
        final Context context = getContext();
        mOpenHelper = new DroidHDDatabase(context);
        return true; 
    /** {@inheritDoc} */ 
    public String getType(Uri uri) {
        final int match = sUriMatcher.match(uri);
        switch (match) {
            case CLIENTES:
                return Clientes.CONTENT_TYPE; 
            case CLIENTES_ID:
                return Clientes.CONTENT_ITEM_TYPE; 
            case CLIENTES_SEARCH:
            	return Clientes.CONTENT_TYPE; 
                throw new UnsupportedOperationException("Unknown uri: " + uri);
    /** {@inheritDoc} */ 
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
            String sortOrder) {
        if (LOGV) Log.v(TAG, "query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")");
        final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        sUriMatcher = buildUriMatcher();
        final int match = sUriMatcher.match(uri);
        switch (match) {
            default: { 
                // Most cases are handled with simple SelectionBuilder 
                final SelectionBuilder builder = buildExpandedSelection(uri, match);
                return builder.where(selection, selectionArgs).query(db, projection, sortOrder);
Connect your IDE to all the code out there  Get Codota for Java