I am trying to add a new crime after getting to page 285 of the 3rd edition of Android Programming and I am getting the error below:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toString()' on a null object reference
at com.bignerdranch.android.criminalintent.CrimeLab.getContentValues(CrimeLab.java:103)
at com.bignerdranch.android.criminalintent.CrimeLab.addCrime(CrimeLab.java:41)
at com.bignerdranch.android.criminalintent.CrimeListFragment.onOptionsItemSelected(CrimeListFragment.java:85)
at android.support.v4.app.Fragment.performOptionsItemSelected(Fragment.java:2317)
The error occurs on this line:
values.put(CrimeTable.Cols.TITLE, crime.getTitle().toString());
I must have typed something wrong but I cannot figure out where. Does the error description give any indication as to what I did wrong? How do I make sure that a newly created crime object is not filled with nulls, or at least not make the application crash when trying to read a new crime object?
Thank you.