Hi, excuse my poor english.
I've used a List to save and retrieve config params using KVS2: it's all ok: if (on the first App start on a smartphone) there are no config data in "datastore", they are created and saved.
When I have tried to use the same criteria, but with my custom variable type (I find it more... elegant), I get an error about a null reference in the "if m24Config = null" condition:
java.lang.NullPointerException: Attempt to write to field 'int b4a.example.main$_typem24conf.refresh' on a null object reference
Any suggestion? Thanks very much
I've used a List to save and retrieve config params using KVS2: it's all ok: if (on the first App start on a smartphone) there are no config data in "datastore", they are created and saved.
When I have tried to use the same criteria, but with my custom variable type (I find it more... elegant), I get an error about a null reference in the "if m24Config = null" condition:
java.lang.NullPointerException: Attempt to write to field 'int b4a.example.main$_typem24conf.refresh' on a null object reference
Any suggestion? Thanks very much
B4X:
' here we are in the Main module
Sub Process_Globals ' tipi e variabili dichiarate solo allo start della App e accessibili da TUTTI I moduli
Type typeNewRecord (ID As Int, titolo As String,intro As String, newUrl As String, imgUrl As String, imgName As String)
Type typeM24Conf (refresh As Int, totNews As Int, notifiche As Boolean)
Public m24Conf As typeM24Conf ' <--- m24Conf is the global custom variable (configuration data)
End Sub
Sub Globals ' tipi e variabili creati ad ogni avvio Activity ed accessibili da questo modulo
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layMain")
If FirstTime Then
' se esiste, recupera configurazione, altrimenti la crea e salva
m24Conf = Starter.kvs.get("m24Conf")
If m24Conf = Null Then
' m24Conf.Initialize
m24Conf.refresh = 20 ' <------------ HERE THE EXCEPTION
m24Conf.totNews = 200
m24Conf.notifiche = False
Starter.kvs.Put("m24Conf", m24Conf)
End If
StartServiceAt(Serv1, DateTime.Now + DateTime.TicksPerSecond, False) 'chiama webservice
End If
End Sub
Last edited: