CoolEgos
CoolEgos

Reputation: 47

How to user ContentProvider only?

These days I go back to see something about ContentProvider but I find some questions.Can I use ContentProvider only?I see many codes,it use ContentProver with Sqlite or SharedPreferences.It means I can't only use ContentProvider to restore,query and update my data.Can you tell some ideas?

Upvotes: 0

Views: 73

Answers (2)

Randyka Yudhistira
Randyka Yudhistira

Reputation: 3652

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.

When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolver object 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.

You don't need to develop your own provider if you don't intend to share your data with other applications. However, you do need your own provider to provide custom search suggestions in your own application. You also need your own provider if you want to copy and paste complex data or files from your application to other applications.

Android itself includes content providers that manage data such as audio, video, images, and personal contact information. You can see some of them listed in the reference documentation for the android.provider package. With some restrictions, these providers are accessible to any Android application.

So, it's not completely related to SQLite or SharedPreferences.

Source : Android Developers

Upvotes: 0

Alex Lockwood
Alex Lockwood

Reputation: 83313

A ContentProvider is an abstraction around an underlying data source. You don't necessarily need to use SQLite (although it is probably the most commonly used), but the ContentProvider will need to use something to store the actual data.

Upvotes: 1

Related Questions