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

Create the Data Source Method

The first step to implementing the simple list is to have data. For this, you need to add a method to the ContactDataSource class that will retrieve each contact’s name. Open ContactDataSource.java and add the code in Listing 6.1 to create a method for getting this data from the database.

Listing 6.1 getContactName Code

public ArrayList<String> getContactName() {    ArrayList<String> contactNames = new ArrayList<String>();                     //1    try {        String query = "Select contactname from contact";                         //2        Cursor cursor = database.rawQuery(query, null);        cursor.moveToFirst();                                                     //3         ...

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