Android Question Checking an object

clooney48

Active Member
Licensed User
Longtime User
Hi!

How can I check if an object is empty (Uri)?? I am not able to do it. I tried it with this code but the if query doesn´t work and the "Cursor.Position = 0" returns an error for the cases that I pressed the return button and the Uri variable is empty.

B4X:
Dim Uri As Object
  Uri = r.RunStaticMethod("android.net.Uri", "parse", _
      Array As Object(UriString), _
      Array As String("java.lang.String"))

If Uri <> Null Then '<< THIS DOESN´T WORK 
  Cursor.Position = 0
  Dim res As String
  res = Cursor.GetString("_data")
  Cursor.Close
  Return res
  End If
 

clooney48

Active Member
Licensed User
Longtime User
Yes I know.
Therefore i put the if statement afterwards to stop executing the rest of the procedure but the if statement doesn´t work and therefore I get an error.
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
When I press the Back button on the phone after the process started I get an error because Uri = ""
 
Upvote 0

eps

Expert
Licensed User
Longtime User
When I press the Back button on the phone after the process started I get an error because Uri = ""

That is not the same as Null. Null means no value, an empty string assigned to a variable then means that it isn't Null, as it has a value, even if that string doesn't have a length.

So null means no value and hasn't had a value.

assigning "" to a string means it hasn't got a length, but it's not null either.

HTH
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
That is not the same as Null. Null means no value, an empty string assigned to a variable then means that it isn't Null, as it has a value, even if that string doesn't have a length.

So null means no value and hasn't had a value.

assigning "" to a string means it hasn't got a length, but it's not null either.

HTH
Thanks for the detailed explanation! Now it is very clear!
 
Upvote 0
Top