Code example for UriMatcher

Methods: addURI

0
 */ 
public class TestTargetContentProvider extends ContentProvider {
    public static final String AUTHORITY = "jp.mixi.sample.test.testtargetcontentprovider";
    public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/tests");
    public static final String TAG = TestTargetContentProvider.class.getSimpleName();
    private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
    private static final String CONTENT_TYPE_TEST_ITEMS = "vnd.android.cursor.dir/vnd.mixi.test";
    private static final String CONTENT_TYPE_TEST_ITEM = "vnd.android.cursor.item/vnd.mixi.test";
    private static final int TYPE_ITEMS = 1;
    private static final int TYPE_ITEM = 2;
    private SQLiteOpenHelper mDatabaseHelper;
 
    // static initializer, which should be run at class loading 
    static { 
        URI_MATCHER.addURI(AUTHORITY, "tests", TYPE_ITEMS);
        URI_MATCHER.addURI(AUTHORITY, "tests/#", TYPE_ITEM);
    } 
 
    @Override 
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        SQLiteDatabase db = null;