Hi All,
New question.
I am attempting save an Array using KVS. The KVS is already working with Lists in the App, the Array works OK until I try to save the Array the same way I save the Lists. Is the KVS the correct way to save an Array? Is there something extra needed to save an Array?
Mock-up code below. When the Array "Recording" is associated with KVS, any attempt to store in the Array results in an error.
java.lang.NullPointerException: array == null
Any help greatfully accepted
Regards Roger
New question.
I am attempting save an Array using KVS. The KVS is already working with Lists in the App, the Array works OK until I try to save the Array the same way I save the Lists. Is the KVS the correct way to save an Array? Is there something extra needed to save an Array?
Mock-up code below. When the Array "Recording" is associated with KVS, any attempt to store in the Array results in an error.
java.lang.NullPointerException: array == null
Any help greatfully accepted
Regards Roger
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private kvs As KeyValueStore
Dim Recording(16,100,2) As String
.......
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim storelist, As List
.................
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Portrait"
If FirstTime Then
storelist.Initialize
For i = 0 To 9
storelist.Add(0)
Next
Dim DataStore_Flag As Int
If File.Exists(File.DirDefaultExternal, "datastore") Then DataStore_Flag = 1 Else DataStore_Flag = 0
kvs.Initialize(File.DirDefaultExternal, "datastore")
If DataStore_Flag = 0 Then
kvs.PutObject("storelist", storelist)
'kvs.PutObject("Recording", Recording)
...........
End If
End Sub
Sub Activity_Resume
storelist = kvs.GetObject("storelist")
'Recording = kvs.GetObject("Recording")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
kvs.PutObject("storelist", storelist)
'kvs.PutObject("Recording", Recording)
End Sub