Android Question Adding and saving data in app

elektor18

Member
Licensed User
Hi,
I'm struggling to save data from spinner element after I add new data. I was tried using StateManager but it didn't save new/additional data after restart.
So for example if I use Spinner.Add("new data or whatever") I would like to have that after I restart app (so basically keep that change in flash memory).
 

elektor18

Member
Licensed User
Data come from EditText box but as name of another/next item on the spinner list. So every time I add new item I want to store it or be able to delete it after application restart or change activity (if I decide to use more then one).
What is KVS2?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Enter kvs2 in the searchbox above and find out by yourself.:)
 
Upvote 0

elektor18

Member
Licensed User
Hi again.
I have read few post about KVS/KVS2 and I found it working but what I want to do is:
Create a list with some String values and every value (command) from that list I would like to assign to spinner item (I want to use it as drop list to pick light effect)
eg.:

String List:
1.Go_to_Flash%14
2.Go_to_Blink%19

Spinner:
1. Flash
2. Slow Blink

How to assign 1.Flash position to send 1.Go_to_Flash%14 command from list?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Create a custom type with the value that goes to the spinner and the command.

Create a list with these custom types. Save it with KVS2.

B4X:
ListOfCommands = kvs.Get("commands") 'ListOfCommands is a process global variable
For Each item As CustomCommand In ListOfCommands
 Spinner.Add(item.SpinnerValue)
Next

'later:
Sub Spinner1_ItemClick (Position As Int, Value As Object)
Dim command As CustomCommand = ListOfCommands.Get(Position)
Log(command)
End Sub
 
Upvote 0
Top