我正在使用UriMatcher和ContentProvider。
uriMatcher.addURI(DbContract.CONTENT_AUTHORITY, DbContract.PATH_CUSTOM_FIELDS + "/" + DbContract.PATH_DOMAIN + "/*", CUSTOM_FIELDS_DOMAIN);
uriMatcher.addURI(DbContract.CONTENT_AUTHORITY, DbContract.PATH_CUSTOM_FIELDS + "/" + DbContract.PATH_DOMAIN + "/" + DbContract.PATH_FORM + "/*/#", CUSTOM_FIELDS_DOMAIN_FORM);
以上所有常数均为: -
DbContract.CONTENT_AUTHORITY = "com.ankiraw";
DbContract.PATH_CUSTOM_FIELDS = custom_fields
DbContract.PATH_DOMAIN = domain
DbContract.PATH_FORM = form
CUSTOM_FIELDS_DOMAIN_FORM = 100
我正在通过uri
content://com.ankiraw/custom_fields/domain/form/ankiraw/38
到
uriMatcher.match(uri)
方法如下: -
switch (uriMatcher.match(uri)) {
case CUSTOM_FIELDS_DOMAIN_FORM:
// some code here
break;
default:
throw new IllegalArgumentException("Cannot query unknown URI " + uri); }
但它不匹配。转向默认情况。