-3
if(  str_driversig != null && str_driversig.length()>0 &&  !str_driversig.contentEquals(null))
    {
}else
    {
        Toast.makeText(context,"Please give Driver Signature",Toast.LENGTH_SHORT).show();
    }

here str_driversig variable vaue like ...../..../signature/81046.png

Always show error below:

UncaughtException: java.lang.NullPointerException: Null reference used for synchronization (monitor-enter)
   at java.lang.String.contentEquals(String.java:958)
   at com.main.exam.ui.driverchecklist.AddDriverChecklist.save_driver_checklist(AddDriverChecklist.java:1318)
   at com.main.exam.ui.driverchecklist.AddDriverChecklist.onClick(AddDriverChecklist.java:367)
   at android.view.View.performClick(View.java:6261)
   at android.widget.TextView.performClick(TextView.java:11185)
   at android.view.View$PerformClick.run(View.java:23752)
   at android.os.Handler.handleCallback(Handler.java:751)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6776)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

1

You are trying to check if the data string equals to null which would be through !str_driversig.contentEquals("null") and not !str_driversig.contentEquals(null). The null is causing the NPE in your case.

Napster
  • 1,353
  • 1
  • 9
  • 11