15、自定义Content Provider

 自定义Content Provider的步骤

   1. 编写一个类,该类必须继承自ContentProvider类。

  1. 实现ContentProvider类中所有的抽象方法。

  2. 定义Content Provider的URI。

  3. 使用UriMatcher对象映射Uri和返回代码。

  4. 根据实际的需要编写相应的方法。

  5. 在AndroidManifest.xml文件中使用<provider>标签注册Content Provider。 

 Content Provider URI 

       URI分为authority和path两部分,其中authority就是 “content://authority”中的authority,相当于网址中的域名,而path 就是“content://authority/”后面的部分,与网址中的路径类似。 

posted on 2014-08-22 16:52  大米稀饭  阅读(456)  评论(0编辑  收藏  举报