content://myprovider/messages
content://myprovider/messages/#
在我的扩展ContentProvider中,我声明了以下内容:
private static final int MESSAGES = 1;
private static final int MESSAGES_ID = 2;
private static final UriMatcher sUriMatcher;
static {
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sUriMatcher.addURI("myprovider", "messages", MESSAGES);
sUriMatcher.addURI("myprovider", "messages/#", MESSAGES_ID);
}
当我使用...
时content://myprovider/messages/#
... Uri在调用任何ContentProvider方法时,比如说insert,而我的ContentProvider方法会调用...
sUriMatcher.match(uri)
...我回来1(MESSAGES)。
为什么???
答案 0 :(得分:1)
如果您想获得MESSAGES_ID
,则必须像content://myprovider/messages/12345
一样编写uri,或者您必须为MESSAGES_ID
添加模式,如:
sUriMatcher.addURI("myprovider", "messages/*", MESSAGES_ID);