Igo*_*pov 9 android android-contentprovider
文档中有明确的推荐用于在实现ContentProvider时定义所有uris .但我对URI匹配器部分感到困惑:例如,我有包org.company.example,表名为'items',然后我定义
public static final Uri CONTENT_URI =
Uri.parse("content://org.company.example.sampleprovider/items");
Run Code Online (Sandbox Code Playgroud)
我应该使用什么权限部分来匹配静态init中的URI:
private static final UriMatcher uriMatcher;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI("what goes here?", "items", ITEM);
uriMatcher.addURI("what goes here?", "items/#", ITEM_ID);
}
Run Code Online (Sandbox Code Playgroud)
Pim*_*sen 14
public static final String PROVIDER_NAME = "org.company.example.sampleprovider";
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME);
private static final UriMatcher uriMatcher;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(PROVIDER_NAME, "items", ITEM);
uriMatcher.addURI(PROVIDER_NAME, "items/#", ITEM_ID);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8616 次 |
| 最近记录: |