Chapter 7. Databases and Content Providers
WHAT'S IN THIS CHAPTER?
Creating databases and using SQLite
Using Content Providers to share application data
Querying Content Providers
Using Cursors and Content Values to read and write from and to Content Providers
Database design considerations
Introduction to the native Content Providers
Using the Contact Content Provider
In this chapter you'll be introduced to the SQLite library, and you'll look at how to use Content Providers to share and use structured data within and between applications.
SQLite offers a powerful SQL database library that provides a robust persistence layer over which you have total control.
Content Providers offer a generic interface to any data source by decoupling the data storage layer from the application layer.
By default, access to a database is restricted to the application that created it. Content Providers offer a standard interface your applications can use to share data with and consume data from other applications — including many of the native data stores.
INTRODUCING ANDROID DATABASES
Structured data persistence in Android is provided through the following mechanisms:
SQLite Databases When managed, structured data is the best approach, Android offers the SQLite relational database library. Every application can create its own databases over which it has complete control.
Content Providers Content Providers offer a generic, well-defined interface for using and sharing data.
Introducing SQLite Databases
Using SQLite ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access