Code example for UriMatcher

Methods: addURI

0
        public static final Uri CONTENT_URI = Uri.parse("content://com.android.cm.mms/templates");
        public static final String TEXT = "text";
    } 
 
    static { 
        sMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        sMatcher.addURI("com.android.cm.mms", "templates", TEMPLATES);
        sMatcher.addURI("com.android.cm.mms", "templates/#", TEMPLATE_ID);
    } 
 
    private static final String TEMPLATE_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS "
            + TABLE_NAME + " (" + Template._ID
            + " integer primary key autoincrement, " + Template.TEXT
            + " text not null);"; 
 
    @Override 
    public boolean onCreate() { 
        DbHelper dbHelper = new DbHelper(getContext(), DB_NAME, null, DB_VERSION);
        mDb = dbHelper.getWritableDatabase();
        return mDb != null;
    }