Android-Content Provider Basics

This topic describes the basics of the following:

  • How content providers work.
  • The API you use retrieve data from a content provider.
  • The API you use to insert, update, or delete data in a content provider.
  • Other API features that facilitate working with providers.
An application accesses the data from a content provider with a ContentResolver client object.
The ContentResolver methods provide the basic "CRUD" (create, retrieve, update, and delete) functions of persistent storage.
权限:android.permission.READ_USER_DICTIONARY;android.permission.WRITE_USER_DICTIONARY
<uses-permission android:name="android.permission.READ_USER_DICTIONARY">

Three alternative forms of provider access are important in application development:

  • Batch access: You can create a batch of access calls with methods in the ContentProviderOperation class, and then apply them with ContentResolver.applyBatch().
  • Asynchronous queries: You should do queries in a separate thread. One way to do this is to use aCursorLoader object. The examples in the Loaders guide demonstrate how to do this.
  • Data access via intents: Although you can't send an intent directly to a provider, you can send an intent to the provider's application, which is usually the best-equipped to modify the provider's data.
ContentProviderOperation    ContentResolver.applyBatch() .

 The application that has permanent permissions grants temporary permissions by setting a flag in the result intent:

A provider defines URI permissions for content URIs in its manifest, using the  android:grantUriPermission attribute of the  <provider>  element, as well as the  <grant-uri-permission>  child element of the <provider>  element. The URI permissions mechanism is explained in more detail in the  Security and Permissions  guide, in the section "URI Permissions".





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值