facebook

[SOLVED] How to make a var persistent?

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #319345 Reply

    WiZaxx
    Participant

    I would like t make a value persistent that in my mind is something that will not change nor return to its original status even after a device reboot.

    In other words:
    …the starting value is 10
    …I change it to 12 and turn-off the device
    …when I return to the app 2 days later and the value is still 12.

    I imagine I will have to write to a file? if so how? or ..?

    #319367 Reply

    support-michael
    Keymaster

    edited Sept 1, see comment below


    @WiZaxx

    You will have to write a bit of javascript code to save and retrieve persisted data but it is pretty easy if your data is simple. The service to use is the HTML5 local storage. There are 2 options:

    1) name-value pair storage
    2) sql DB storage

    Here is a good intro. Use google to find others.

    Correction: The Test Center properly supports persisted local storage across sessions since 1.2. In my original reply I mistakenly stated that it did not.

    #319417 Reply

    support-michael
    Keymaster

    @WiZaxx

    See the edited reply above.

    #319438 Reply

    WiZaxx
    Participant

    I’m using this format to set the local storage pair from an input box:

      localStorage.setItem("varDepTransfer", document.getElementById('m1-settings-textDepTransfer').value);

    and this format to retrieve the data into the same input box when loading the document:

      document.getElementById('m1-settings-textDepTransfer').value = localStorage.getItem("varDepTransfer");

    It works perfectly.

    Thank you

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [SOLVED] How to make a var persistent?

You must be logged in to post in the forum log in