这是我的Uri Matcher
static UriMatcher buildUriMatcher() {
UriMatcher mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
// Bind uriMatcher int constants and uris
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_DRIVE, DRIVE_LIST);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_DRIVE + "/#", DRIVE_ID);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_FILE, FILE_LIST);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_FILE + "/*", FILE_ID);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_FILE + "/drive/#", FILE_LIST_WITH_DRIVE_ID);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_FILE + "/file/*", FILE_LIST_WITH_FOLDER_ID);
mUriMatcher.addURI(OneSpaceContract.CONTENT_AUTHORITY, OneSpaceContract.PATH_FILE + "/drive/#/*", FILE_LIST_WITH_DRIVE_ID_AND_FOLDER_ID);
// Return the new matcher!
return mUriMatcher;
}
这是PATH_FILE常量
public static final String PATH_FILE = "file";
UriMatcher与我的uri不匹配
Uri:content://olexiimuraviov.ua.onespace_diplomaproject/file/drive/11/root
这是一个例外
java.lang.UnsupportedOperationException:
Unknown uri: content://olexiimuraviov.ua.onespace_diplomaproject/file/drive/11/root
at OneSpaceProvider.query(...)
我尝试调试但什么都没发现。 Uri模式看起来很好,并且给予uri也很好,但匹配器并不匹配。你能帮我解决这个问题吗?提前谢谢!
答案 0 :(得分:2)
正如塞尔文在他的例子中所说,有问题的规则是绑定FILE_ID的规则。段的第一部分匹配,因此它不会尝试查找在该段匹配的任何其他规则。最后移动该规则,它应该没问题。