内容提供
2015-06-08 23:08
162 查看
调用内容提供 提供者不用启动
1 继承ContentProvider
重写方法
2 在onCreate中匹配器注册uri格式的权限
UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
内容使用者
1 创建连接解析器
ContentResolver r = this.getContentResolver();
2 把字符串解析成uri
Uri uri=Uri.parse("content://com.tarena.provider.WORD/x");
content://com.tarena.provider.WORD/words/9
结尾的words只是传入了选择方法钥匙
3 使用r+uri调用内容提供器的方法
r.query(uri,...)
r.delete(uri,...)
传入的uri:content://com.tarena.provider.WORD/words/9
long id = ContentUris.parseId(uri);解析出的是 9
是使用内容者向提供者提供的参数
int code = matcher.match(uri);解析出的是 words所代表的 1
在matcher.addURI("com.tarena.provider.WORD", "words/#", 1)中设置
是向提供者判断采用那种方法的钥匙 是提供者事先规定好的
1 继承ContentProvider
重写方法
2 在onCreate中匹配器注册uri格式的权限
UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
内容使用者
1 创建连接解析器
ContentResolver r = this.getContentResolver();
2 把字符串解析成uri
Uri uri=Uri.parse("content://com.tarena.provider.WORD/x");
content://com.tarena.provider.WORD/words/9
结尾的words只是传入了选择方法钥匙
3 使用r+uri调用内容提供器的方法
r.query(uri,...)
r.delete(uri,...)
传入的uri:content://com.tarena.provider.WORD/words/9
long id = ContentUris.parseId(uri);解析出的是 9
是使用内容者向提供者提供的参数
int code = matcher.match(uri);解析出的是 words所代表的 1
在matcher.addURI("com.tarena.provider.WORD", "words/#", 1)中设置
是向提供者判断采用那种方法的钥匙 是提供者事先规定好的
相关文章推荐
- Android NDK(学习笔记四)—— 在NDK开发中JNI打印Log信息
- POJ - 1274 The Perfect Stall 二分图 最大匹配
- [031] 微信公众帐号开发教程第7篇-文本消息中换行符的使用
- DNX/ASP.NET 5的xUnit入门向导
- 18岁生日
- 第十篇 SQL Server代理使用代理帐户
- 集群负载均衡算法原理
- 黑马程序员——Java基础—GUI
- android顺序广播
- C#超级实用的一种类型—匿名类型
- NOIP 2014 D1T2 -联合权值
- Android模拟器与局域网通信
- Zoj 3469 Food Delivery (DP
- Android入门---下拉刷新上拉加载更多策略的实现
- 第六题
- linux 和 hp 上如何生成core文件
- java_类排序模板(类似于C++结构体)
- 慕课网HTML5学习笔记
- Apktool回编译问题解决方案总结
- 面试算法java方式实现打印金字塔三角形