Android Question KeyValueStore - List question

jtare

Active Member
Licensed User
Longtime User
Hi, I'm trying to store a List with this code:
B4X:
list22.Add(Array As String(EditText2.Text,EditText1.Text))
Starter.kvs.Put("ContactList", list22)

How can I read this data?
One of the many things I tried (without success) was this:
B4X:
Dim mytypes2 As Object = Starter.kvs.Get("ContactList")
list22.Initialize2(mytypes2)     
If Starter.kvs.ContainsKey("ContactList") Then
  For i=0 To list22.Size-1
       Dim mytypes3() As String = list22.Get(i)
       friendlistview.AddSingleLine2(mytypes3(0) , mytypes3(1) )
  Next
End If

And also this
B4X:
Dim mytypes2() As List = Starter.kvs.Get("ContactList")
    
If Starter.kvs.ContainsKey("ContactList") Then
  For i=0 To list22.Size-1
       friendlistview.AddSingleLine2(mytypes2(0).Get(i) , mytypes2(1).Get(i))
  Next
End If

Any idea on how to read the array?
 

Mahares

Expert
Licensed User
Longtime User
Is this what you want:
B4X:
Dim friendlistview As ListView
    Dim list22 As List
    list22.Initialize
  
    list22.Add(EditText2.Text & "," & EditText1.Text)  'edit 2/27/16
    list22.Add(EditText4.Text & "," & EditText3.Text)  'edit 2/27/16
    Starter.kvs.Put("ContactList", list22)

     Dim MyList As List = Starter.kvs.Get("ContactList")
     For i=0 To MyList.Size-1
        Dim v() As String= Regex.Split(",", MyList.Get(i))
        friendlistview.AddSingleLine2(v(0) , v(1))
     Next

EDIT: 2 lines above: 2/27/16 9:40 PM GMT
 
Last edited:
Upvote 0

jtare

Active Member
Licensed User
Longtime User
Is this what you want:
B4X:
Dim friendlistview As ListView
    Dim list22 As List
    list22.Initialize
    list22.Add(Array As String(EditText2.Text & "," & EditText1.Text))
    list22.Add(Array As String(EditText4.Text & "," & EditText3.Text))
    Starter.kvs.Put("ContactList", list22)

     Dim MyList As List = Starter.kvs.Get("ContactList")
     For i=0 To MyList.Size-1
        Dim v() As String= Regex.Split(",", MyList.Get(i))
        friendlistview.AddSingleLine2(v(0) , v(1))
     Next

Thanks for the reply!, I changed I little bit the code you posted and so far is working!, Thanks!
I removed the Array As string part in list22.Add because it was crashing my app.

B4X:
     list22.Add(EditText2.Text & "," & EditText1.Text)
     Starter.kvs.Put("ContactList", list22)

Dim MyList As List = Starter.kvs.Get("ContactList")
     list22.Initialize2(MyList)
For i=0 To list22.Size-1
Dim v() As String= Regex.Split(",", list22.Get(i))
     friendlistview.AddSingleLine2(v(0) , v(1))
Next
 
Upvote 0
Top