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 Class

Create a new class named ContactDataSource. Enter the code in Listing 5.2, being sure to import any objects underlined in red.

Listing 5.2 ContactDataSource Required Code

public class ContactDataSource {    private SQLiteDatabase database;                                              //1    private ContactDBHelper dbHelper;    public ContactDataSource(Context context) {                                   //2        dbHelper = new ContactDBHelper(context);    }    public void open() throws SQLException {                                      //3        database = dbHelper.getWritableDatabase();    }    public void close() {                                                         //4         ...

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