android Content Providers 内容提供者

Content Providers(内容提供者)

Content providers 可以访问和管理结构化数据集。它们封装了数据,并提供一种机制来定义数据安全。Content providers是一种标准的接口定义,它可以从一个线程中访问另外一个线程的数据。

当您想通过content provider访问数据,您需要借助ContentResolver对象,ContentResolver 对象可以通过Context获得,ContentResolver就相当于ContentProvider的客户端。ContentResolver对象与provider对象进行通信,这个provider实现了ContentProvider。provider接受resolver的请求,处理请求并返回结果。

当您不想与其他的应用共享数据,可以不提供provider。但是,你需要你自己的provider来提供自定义搜索建议在您自己的应用程序。如果您想从您的应用中复制和粘贴复杂的数据或者文件到其他的应用里面,还是需要提供provider。

android自带有管理数据的providers,包括audio,video,images,and 通讯录信息。您可以到android.provider 包下面了解更加详细的信息。

The following topics describe content providers in more detail:

Content Provider Basics
如何通过content provider访问数据。
How to access data in a content provider when the data is organized in tables.
Creating a Content Provider
创建一个content provider
How to create your own content provider.
Calendar Provider
如果调用日历provider,
How to access the Calendar Provider that is part of the Android platform.
Contacts Provider
如何调用通讯录provider
How to access the Contacts Provider that is part of the Android platform.
原文地址:https://www.cnblogs.com/java20130722/p/3207294.html