private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); private static final int PEOPLE = 1; private static final int PEOPLE_ID = 2; static { //#代表匹配任意数字,*代表任意文本 URI_MATCHER.addURI("AUTHORITY", "peple", PEOPLE); URI_MATCHER.addURI("AUTHORITY", "peple/#", PEOPLE_ID); } private void doSomthing(Uri uri) { int match = URI_MATCHER.match(uri); switch (match) { case PEOPLE: break; case PEOPLE_ID: break; default: break; } }