Android URI Connector Problem

I have an authorization string defined as such:

public final static String AUTHORITY = "dsndata.sds2mobile.jobprovider";

According to the editors of UriMatcher:

uriMatcher.addURI(JobMetaData.AUTHORITY, "/JobNames/*",
                      JOBNAME_SINGLE_URI);

Uri, which is passed to the switch:

content://dsndata.sds2mobile.jobprovider/JobNames/test

This happens through the switch and removes the default value (which throws an IllegalArgumentException).

Am I missing something? I searched and cannot find anything that could explain the discrepancy.

+3
source share
2 answers

I also had a problem with IllegalArgumentException. Even those who debug Uri were the same! [drove me crazy]. If you first defined * / match, which seems like a match and an obstacle to other users. ORDER IMPORTANT !!

I reordered and 'external_warning_id' now works fine.

//putting it first as /* seems to get matched first
    URL_MATCHER.addURI(AUTHORITY, TABLE_NAME.toLowerCase() + "/external_warning_id" + "/*",
            EXTERNAL_WARNING_ID);

// was the first entry in static block
URL_MATCHER.addURI(AUTHORITY, TABLE_NAME.toLowerCase() + "/*", WARNING__ID);
+6

:

uriMatcher.addURI(JobMetaData.AUTHORITY, "JobNames/*",
                  JOBNAME_SINGLE_URI);

uriMatcher.addURI(JobMetaData.AUTHORITY, "/JobNames/*",
                  JOBNAME_SINGLE_URI);

()

, . , , - . , .

+4

Source: https://habr.com/ru/post/1786029/


All Articles