ContentProvider

目录

  • 概述
  • 运行时权限
  • 访问内容提供器
  • 实现内容提供器

概述

内容的形式是内容Uri,存在数据库中
对内容的操作有query insert update delete

运行时权限

运行时权限.jpg

访问内容提供器

  • ContentResolver
  • 内容Uri scheme+authority+path+IDcontent://com.example.app.provider/table/1
  • CRUD query() insert() update() delete()

创建内容提供器

  • 创建被分享的内容Uri

  • 创建UriMatcher

  • onCreate()

  • query(Uri)

  • insert(Uri)

  • update(Uri)

  • delete(Uri)

  • getType(Uri) 用于获取Uri对应的MIME类型vnd.android.cursor.dir/vnd.com.example.app.provider/table1

  • UriMatcher用来匹配内容Uri,只匹配希望被访问到的内容

posted @ 2017-07-18 20:40  s3abiscuit  阅读(98)  评论(0编辑  收藏  举报