O'Reilly logo

Professional Android™ 2 Application Development by Reto Meier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required