private static final UriMatcher uriMatcher; static { uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); uriMatcher.addURI(PROVIDER_NAME, "sampleuri1", SAMPLE1); uriMatcher.addURI(PROVIDER_NAME, "sampleuri1/#", SAMPLE1_ID); uriMatcher.addURI(PROVIDER_NAME, "sampleuri2", SAMPLE2); uriMatcher.addURI(PROVIDER_NAME, "sampleuri2/#", SAMPLE2_ID); }
@Override public boolean onCreate() { String packageName = getContext().getPackageName(); AUTHORITY = packageName + ".provider.email"; CONTENT_URI = Uri.parse("content://" + AUTHORITY); uriMatcher.addURI(AUTHORITY, "account/*/messages", MESSAGES); uriMatcher.addURI(AUTHORITY, "account/*/messages/threaded", MESSAGES_THREADED); uriMatcher.addURI(AUTHORITY, "account/*/thread/#", MESSAGES_THREAD); return true; }
@Override public void attachInfo(Context context, ProviderInfo info) { super.attachInfo(context, info); TRANSACTION_URI = Uri.parse("content://" + info.authority + "/transaction"); matcher.addURI(info.authority, "transaction/#", TRANSACTION); matcher.addURI(info.authority, "transaction", TRANSACTIONS); }
static void setAuthority(final String authority) { sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH); sURIMatcher.addURI(authority, TrayContract.Preferences.BASE_PATH, ALL_PREFERENCE); // BASE/module sURIMatcher.addURI(authority, TrayContract.Preferences.BASE_PATH + "/*", MODULE_PREFERENCE); // BASE/module/key sURIMatcher.addURI(authority, TrayContract.Preferences.BASE_PATH + "/*/*", SINGLE_PREFERENCE); sURIMatcher.addURI(authority, TrayContract.InternalPreferences.BASE_PATH, INTERNAL_ALL_PREFERENCE); // INTERNAL_BASE/module sURIMatcher.addURI(authority, TrayContract.InternalPreferences.BASE_PATH + "/*", INTERNAL_MODULE_PREFERENCE); // INTERNAL_BASE/module/key sURIMatcher.addURI(authority, TrayContract.InternalPreferences.BASE_PATH + "/*/*", INTERNAL_SINGLE_PREFERENCE); }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
/** * Register a {@link QueryHandler} to handle a certain {@link Uri} for * {@link #query(Uri, String[], String, String[], String)} */ protected void registerQueryHandler(QueryHandler handler) { if (queryHandlers.contains(handler)) { return; } queryHandlers.add(handler); int code = queryHandlers.indexOf(handler); uriMatcher.addURI(AUTHORITY, handler.getPath(), code); }