Android Question Adding and saving data in app

Discussion in 'Android Questions' started by elektor18, Aug 13, 2018.

  1. elektor18

    elektor18 Member Licensed User

    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).
  2. Erel

    Erel Administrator Staff Member Licensed User

    Spinner is an UI element. It has two responsibilities: show the values to the user and let the user choose a value.

    Where does the data come from?

    You need to store the list. A good way to do it is with KVS2.
    Peter Simpson likes this.
  3. elektor18

    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?
  4. DonManfred

    DonManfred Expert Licensed User

    Enter kvs2 in the searchbox above and find out by yourself.:)
    Peter Simpson likes this.
  5. elektor18

    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)

    String List:

    1. Flash
    2. Slow Blink

    How to assign 1.Flash position to send 1.Go_to_Flash%14 command from list?
  6. Erel

    Erel Administrator Staff Member Licensed 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.

    ListOfCommands = kvs.Get("commands"'ListOfCommands is a process global variable
    For Each item As CustomCommand In ListOfCommands

    Sub Spinner1_ItemClick (Position As Int, Value As Object)
    Dim command As CustomCommand = ListOfCommands.Get(Position)
    End Sub
  7. elektor18

    elektor18 Member Licensed User

    Thank you Erel,
    I applied accordingly and it works :) Thank you again.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice