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.
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 ...
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.