December 2013
Intermediate to advanced
464 pages
14h 46m
English
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 ...
Read now
Unlock full access