I try to use this code below to fill a list using DBUtils.ExecuteToList and if the list is null, I fill the list using add the values manually, but I get this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.collections.List.AddAll(anywheresoftware.b4a.objects.collections.List)' on a null object reference
How I can do this (if list is null, fill it using other values)?
If I initialized the list (lst.Initialize) in If...Then I get this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.collections.List.Initialize()' on a null object reference
Thanks in advance for any tip.
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.collections.List.AddAll(anywheresoftware.b4a.objects.collections.List)' on a null object reference
How I can do this (if list is null, fill it using other values)?
B4X:
Dim lst As List
lst = DBUtils.ExecuteToList(Starter.SQL1, "Select name FROM contacts ORDER BY name", "name", 0, 0)
If (lst = Null) Then
ToastMessageShow("There is no names in the list."&CRLF&"Using default values.", False)
'lst.Initialize
lst.AddAll(Array As String("Name 01","Name 02","Name 03"))
End If
If I initialized the list (lst.Initialize) in If...Then I get this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.collections.List.Initialize()' on a null object reference
Thanks in advance for any tip.