Android Question Retrieving a Null Value

peggjones

Active Member
Licensed User
Longtime User
How can I ignore a null value?

When I execute code like the following

Log(Cursor.GetString("number"))

If number contains a null I would like to just ignore it rather than have the program fall over.

Is there any an easy way to do this?

Many Thanks
 

Peter Simpson

Expert
Licensed User
Longtime User
Have you tried placing your code within the Try statement? Personally I would try the code below. If that does not work then just change your SQL query to replace Null with a 0.

Just a quick guess as I'm typing using my phone.
B4X:
Try
     Number = Cursor.GetString("number")
Catch
     Log(LastException.Message)
     Return
End Try
 
Last edited:
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
Here is my version :
B4X:
Lbl.Text = GetString(1)
If(Lbl.Text = "null") Then Lbl.Text = ""
 
Upvote 0
Top