[Android] Content provider, ContentResolver

Content provider的作用:

Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.

 

在MainFast中需要注册一个provider, content provider 和 Activity 一个级别,所以需要在MainFast中写明:

 <provider android:name=".PersonProvider"
            android:authorities="thenewboston.providers.personProvider"></provider>

authorities是内容提供者的唯一标识。

 

ContentResolver是用来访问数据的。

When you want to access data in a content provider, you use theContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolverobject communicates with the provider object, an instance of a class that implements ContentProvider. The provider object receives data requests from clients, performs the requested action, and returns the results.

 

posted @ 2014-07-01 17:30  Zhentiw  阅读(246)  评论(0编辑  收藏  举报