java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String java.lang.String.toString()’ on a null object reference
at pritish.sawant.com.criminalintent.CrimeLab.getContentValues(CrimeLab.java:47)
at pritish.sawant.com.criminalintent.CrimeLab.addCrime(CrimeLab.java:55)
at pritish.sawant.com.criminalintent.CrimeListFragment.onOptionsItemSelected(CrimeListFragment.java:192)
at android.support.v4.app.Fragment.performOptionsItemSelected(Fragment.java:2317)
at android.support.v4.app.FragmentManagerImpl.dispatchOptionsItemSelected(FragmentManager.java:3056)
at android.support.v4.app.FragmentController.dispatchOptionsItemSelected(FragmentController.java:353)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:414)
at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195)
at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113)
at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:679)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:959)
at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:623)
at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:154)
at android.view.View.performClick(View.java:5333)
at android.view.View$PerformClick.run(View.java:21792)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5819)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Ignore this.I figured it out
@pritish I have encountered this problem. How did you solve it?
I do not see people answering this question. I got the same error and already fix it out.
I have added a initialization in the Crime construction as an empty string to mTitle. Otherwise it would be null which would create a exemption when calling .getTitle().toString().