Im using ExecQuerySingleResult to get a value out of a database. Sometime the value is null (to be expected) so I need to check if its null.
However my app is throwing a java.lang.NullPointerException when I try to test the value of the resulting string.
Code is like this;
Dim result As String
result = Main.DB.ExecQuerySingleResult(...)
If I check result.length its fine however if I use result.contains("X") then I get the NullPointerException
If I Log(result) it shows null but even if I test for "null" (ie a sting) or just null (as in null) its still passing the test.
If result .Length > 0 then 'Passes
If result <> "null" then 'Passes
If result <> Null then 'Passes
If result.Contains("appid=") = False Then 'NullPointerException
What is the best/safe way to test for a null value?
However my app is throwing a java.lang.NullPointerException when I try to test the value of the resulting string.
Code is like this;
Dim result As String
result = Main.DB.ExecQuerySingleResult(...)
If I check result.length its fine however if I use result.contains("X") then I get the NullPointerException
If I Log(result) it shows null but even if I test for "null" (ie a sting) or just null (as in null) its still passing the test.
If result .Length > 0 then 'Passes
If result <> "null" then 'Passes
If result <> Null then 'Passes
If result.Contains("appid=") = False Then 'NullPointerException
What is the best/safe way to test for a null value?