Android Question Error !! the app is crashing (EqualsIgnoreCase)

qey

Member
HI !! Im new with B4A. Im having this error. Can anyone help ?

Convert null:
Sub convertNull(val As String) As String
    If val.EqualsIgnoreCase("null") Then
        val=""
    End If
    Return val
End Sub



Error occurred on line: 752
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference
at com.xfs.xfsPnD.xfs._convertnull(xfs.java:1234)
at com.xfs.xfsPnD.jobtableclass._savejobstatuslist(jobtableclass.java:2144)
at com.xfs.xfsPnD.jobtableclass._parsejobsstatuslist(jobtableclass.java:2093)
at com.xfs.xfsPnD.registerservice._jobdone(registerservice.java:663)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:200)
at android.app.ActivityThread.main(ActivityThread.java:6971)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 

qey

Member
The null come from the database. i need this code to catch null string value.

is it possible if i change the code like this ?

catch null string:
Sub convertNull(val As String) As String
    If val <> Null Then
        val=""
    End If
    Return val
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…