Android UriMatcher构造函数中的代码参数是什么意思?
UriMatcher(int-code)构造函数中的代码参数根据用于“匹配根URI”的 它的值等于-1Android 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
我不清楚为什么要将此值和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(""))));