O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

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

Populating the ContactActivity Screen

You’ve learned how to get a list to respond to the selection of a contact in the list by opening the ContactActivity and passing a contact’s ID value to it. The next step is to get the ContactActivity to use that ID to retrieve the contact’s data and display it.

Open the ContactDataSource.java file and add a method to retrieve a specific contact based on the contact’s ID. Use the code in Listing 6.14 to create the method. This code is essentially the same as the getContacts method, except that it returns a single contact rather than an ArrayList of all the contacts.

Listing 6.14 GetSpecificContact Method

public Contact getSpecificContact(int contactId) {                                //1 ...

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