Set ContactActivity as Default Activity with no Contacts in Database

The final task is to modify the onResume method of the ContactListActivity to check if there are any contacts in the database. If there are not, the app should open the ContactActivity. Refer to Listing 6.20 to make these changes.

Listing 6.20 Modify the onResume Method to Check for Contacts

if (contacts.size() > 0) {                                                        //1    adapter = new ContactAdapter(this, contacts);    setListAdapter(adapter);    ListView listView = getListView();    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {        @Override        public void onItemClick(AdapterView<?> parent, View itemClicked, ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.