UriMatcher的用法

来源:互联网 发布:linux安全认证 编辑:程序博客网 时间:2024/06/07 04:58
 private static final String AUTHORITY = "com.example.cmomp";      private static final int PEOPLE = 1;      private static final int PEOPLE_ID = 2; 

public String m(){UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);matcher.addURI("com.example.cmomp", "people", PEOPLE);matcher.addURI("com.example.cmomp", "person/#", PEOPLE_ID);Uri uri = Uri.parse("content://" + "com.example.cmomp" + "/people");int match = matcher.match(uri);switch (match) {case PEOPLE:return "vnd.android.cursor.dir/people";case PEOPLE_ID:return "vnd.android.cursor.item/people";default:return null;}}








原创粉丝点击