Android Question Empty/Null String matching - debugger quirk?

philster

Member
Licensed User
Longtime User
Hi

At runtime the following will fail if the string variable (jp_player.time) is NULL....

//BA.debugLineNum = 85;BA.debugLine="If jp_player.time <> \"\" Then";
if ((_jp_player.red_time).equals("") == false) {

.....but when stepping through the code in the debugger it does not pick this up and treats it as an empty string "" and doesn't crash.

The error I'm referring to is:-

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

Is this a bug? I'm using b4a 5.5.
 

philster

Member
Licensed User
Longtime User
How is the null assigned to this variable?
I will need to double check this next week but I'm fairly sure it's null on the SQLite database and the variable is populated using a cursor getstring, e.g.:-

var = cursor1.getstring("varchar col")

Thanks
Phil
 
Upvote 0
Top