CHAPTER 14: Android Content Providers: Providing Data to Applications 511
As mentioned, if you browse the current Android Developer website documentation, you will find
that these interfaces listed in Table 14-1 are all described as being deprecated. The reason that
these are called interfaces is because they define how and where you are going to interface with the
data, using the format database.table, so a table that has people in it is referenced using
Contacts.PeopleColumns, as you can see in Table 14-1, row 3.
Deprecated Database Structures: Software Upgrades
Deprecated is a programming term that means that classes, methods, constants, interfaces, or
databases have been replaced by other more modern programming structures. This usually happens
during the release of newer versions of a programming language (such as Java) or an API (such as
Android).
These newer structures replace the older structures and are usually more robust (fewer bugs)
or more complex, but sometimes they differ only in how they are implemented. In the case of a
database, they sometimes differ in the fields of data that are contained in the database tables.
This deprecation is exactly what has happened with the Contacts database interfaces between
Android versions 1.x (1.0, 1.1, 1.5, and 1.6) and 2.0, and Android versions 2.1, 3.x, 4.x (2.1, 2.2, 2.3,
3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 4.3, and 4.4) and 5.0. So database interfaces that work on Android 1.x and
2.0 phones are different than the ones that work on Android 2.1, 3.x, 4.x and 5.0 phones. The newer
versions use more advanced, feature-rich database structures in ContactsContract.
If you are going to support 1.5, 1.6, or 2.0 phones, you need to use the database interfaces listed in
Table 14-1. This book uses the Android suggested application support default settings of API Level 8
(Android 2.2) through API Level 19 (Kit Kat 4.4), as you learned in Chapter 3, so you need to use
more advanced database structures that replace the original database structures in Android Level 7
(Android 2.1).
The good news is that deprecated does not mean disabled. In this case, it more accurately means,
“not suggested for general use unless you need to support pre-2.1 versions for your Android users.”
So, if you need to support Android 1.5, 1.6, and 2.0 phones, you can use the interfaces listed in
Table 14-1. Note that inside Eclipse, deprecated structures and method calls are lined out in the
Java code, to show the developer that they are deprecated.
That can be a bit unnerving, since most devices these days are 2.3.7 through 4.4-compatible,
so I suggest you take Android’s “advice” and develop for API Levels 8 through 19 or later. This is
suggested in the Create New Android Application Project series of dialogs, which you encountered
in Chapter 3 (refer to Figure 3-3 to see the API Level defaults).
You will not be able to access data from newer database tables until you add support for the 2.1,
3.x, and 4.x DBMS structures in your code. You can do this by detecting which OS your user is
using, and having code sections that deal with each (1.x and 2.0 versus 2.1, 3.x, 4.x or 5.x) database
access structure differently, using different ContentProvider and ContentResolver code.
Note If you want to be able to access every new feature, you can always have your Java code detect
which version of Android a device is using, and then use custom code that delivers your optimal application
functionality for each specific Android OS version.