Android Sqlite insert null object reference : <p>I'm taking an intro to android programming course running into some issues adding to the sqlite database</p>

<p>Any suggestions what might be causing this error. I think it is related to not having the proper assignment to the mDatabase field variable. </p>

<p>It seems like the issue is that mDatabase variable in the addCustomer function needs different context.</p>

<pre><code>  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"); 
 } 
</code></pre>

<p>File Links on Github below:</p>

<p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerBaseHelper.java" rel="nofollow noreferrer">CustomerDataBase.java</a></p>

<p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerCursorWrapper.java" rel="nofollow noreferrer">CustomerCursorWrapper.java</a></p>

<p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerDbSchema.java" rel="nofollow noreferrer">CustomerDBSchema.java</a></p>

<p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/Customer.java" rel="nofollow noreferrer">Customer.java</a></p>

<p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/AddCustomerActivity.java" rel="nofollow noreferrer">AddCustomerActivity.java</a></p>
