Chapter 4

Content Providers

WHAT’S IN THIS CHAPTER?

  • 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

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

Please note that all the code examples in this chapter are available at https://github.com/wileyenterpriseandroid/Examples.git and as a part of the book’s code download at www.wrox.com 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.