I'm taking an intro to android programming course running into some issues adding to the sqlite database
Any suggestions what might be causing this error. I think it is related to not having the proper assignment to the mDatabase field variable.
It seems like the issue is that mDatabase variable in the addCustomer function needs different context.
private static ContentValues getContentValues(Customer customer) {
ContentValues values = new ContentValues();
values.put(UUID, customer.getId().toString());
values.put(FULL_NAME, customer.getName());
values.put(ADDRESS, customer.getAddress());
values.put(CREDIT_CARD_NUMBER, customer.getCreditCardNumber());
values.put(EMAIL, customer.getEmail());
values.put(SESSIONS_REMAINING, customer.getSessionsRemaining());
values.put(PRINT_RECEIPT, customer.getPrintReceipt() ? 1 : 0);
values.put(EMAIL_RECEIPT, customer.getEmailReceipt() ? 1 : 0);
return values;
}
public void addCustomer(Customer c) {
ContentValues values = getContentValues(c);
mDatabase.insert(CustomerDbSchema.CustomerTable.NAME, null, values);
Log.d("DATABASE", "Customer Added");
}
File Links on Github below: