UriMatcher不匹配Uri?我在uri中使用*和#,这是不允许的?

时间:2018-01-02 04:58:51

标签: android

我正在使用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); }

但它不匹配。转向默认情况。

0 个答案:

没有答案