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,只匹配希望被访问到的内容

Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind
原文地址:https://www.cnblogs.com/s3abiscuit/p/7202595.html