Home > Articles > Home & Office Computing > Entertainment/Gaming/Gadgets

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Benefits of Content Providers

The above data-sharing mechanism presents the benefit of a platform-wide pattern for data sharing. If you want to access the data of an installed application, or some other system data, you have a single interface against which you can perform queries and manipulations.

This standard means that Android developers can approach inter-application data exchange with some predefined expectations because you cannot deviate from the methods provided by the ContentProvider interface.

Data is provided by the ContentProvider interface, but exposed by the ContentResolver. You could potentially access the implemented ContentProvider via Activity.getContentResolver().getProvider(). However, doing so would couple the requesting class to the implemented ContentProvider

Further to this standardized pattern, the ContentResolver provides several interesting functionalities. For instance, it will notify any content listener that the data has changed. For example, you could listen to any changes occurring within a user's contacts and act upon it.

The resolver can also enable data syncing—with a website or any other client/server applications. The syncing and notifying will be up to the content provider to implement. If you update a row into the database being exposed, you will need to notify the ContentResolver of that update.

  • + Share This
  • 🔖 Save To Your Account