One reader of my book Android 7 pointed out that one of the samples was showing duplicate contacts. It turns out that this small glitch is present in the latest edition, too. In the just released Android 8 edition the bug is in Listing 5.13, MiniContacts.java, on page 198:

In methd onCreateLoader() the wrong class is accessed. Instead of Data we need to use Contacts:

@Override

public Loader <Cursor> onCreateLoader(int id, Bundle args) {
  return new CursorLoader(this,
             ContactsContract.Contacts.CONTENT_URI,
             PROJECTION, SELECTION, null, null);
}

The Bitbucket repo Begleitmaterialien zu “Android 8” contains the fixed version. In the earlier edition, Android 7, the bug appears on page 200.


This is a (slightly updated) repost of a piece I published on my blog Tommi’s Blog. I deleted the blog in the wake of the GDPR, so the original version is no longer available, or only through the WayBack Machine of the Internet Archive. Please note: code usually has not been updated, so language feature reflect the time the original post was written.