Chapter 4

Content Providers


  • Using content providers
  • Publishing a contract: URIs and types
  • Implementing a content provider
  • Controlling access to your content provider with permissions and registration
  • Understanding content provider file operations


Please note that all the code examples in this chapter are available at and as a part of the book’s code download at on the Download Code tab.

Content providers are the foundation for the rest of this book. In this chapter you will meet content providers and the tools used to build them. In addition you are introduced to the REST-like architecture they support and how that architecture enables the use of Android in the enterprise. The application created in this chapter can be found in the project KeyValCP.

The techniques introduced in the previous chapter — creating a globally accessible reference to a database object — might be appropriate for a small application. In more complex applications, however, developers will require better architectural separation between data management and other components of their application.

The Android content provider framework has several parts:

  • Contract — A Java source file that publishes symbols and constants that external processes need to access the provider. External applications include this file as part of their source.
  • Content Resolver — A part of the Android ...

Get Enterprise Android: Programming Android Database Applications for the Enterprise now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.