Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android UriMatcher构造函数中的代码参数是什么意思?_Android_Android Contentprovider - Fatal编程技术网

Android UriMatcher构造函数中的代码参数是什么意思?

Android UriMatcher构造函数中的代码参数是什么意思?,android,android-contentprovider,Android,Android Contentprovider,UriMatcher(int-code)构造函数中的代码参数根据用于“匹配根URI”的 它的值等于-1 我不清楚为什么要将此值和getType methode中的uri与addUri methode中的uri进行匹配?当使用既不包含权限也不包含路径的uri调用时,您提供给UriMatcher构造函数的整数代码由match()返回 这表明了以下行为: UriMatcher m = new UriMatcher(999); m.addURI("com.example

UriMatcher(int-code)构造函数中的代码参数根据用于“匹配根URI”的 它的值等于-1


我不清楚为什么要将此值和getType methode中的uri与addUri methode中的uri进行匹配?

当使用既不包含权限也不包含路径的
uri
调用时,您提供给
UriMatcher
构造函数的整数代码由
match()
返回

这表明了以下行为:

        UriMatcher m = new UriMatcher(999);

        m.addURI("com.example", "pathsegment", 11);

        //found; code= 11
        Log.i("Test", String.format("Match code= %d", m.match(Uri.parse("content://com.example/pathsegment"))));
        //not found; code= -1
        Log.i("Test", String.format("Match code= %d", m.match(Uri.parse("content://com.example/xxxxxx"))));
        //root; code= 999
        Log.i("Test", String.format("Match code= %d", m.match(Uri.parse("content:"))));
        //root; code= 999
        Log.i("Test", String.format("Match code= %d", m.match(Uri.parse(""))));