Android Question Save fields values/state while rotating device

Discussion in 'Android Questions' started by agb2008, Apr 23, 2015.

  1. agb2008

    agb2008 Member Licensed User

    In my application I am trying to implement solution that would allow to preserve inputted vales in EditText fields, state of Spinner objects (selected item), Labels values and viability of different panels and objects... Also I would like to avoid external storage option - to just keep minimum (or better to say none additional requirements from Android OS point of view)

    Could you please advice how correct would be such solution:

    1. Define variables for required objects in Process_Globals Sub (of different types i.e. Double, Int, String, Boolean e.t.c.)
    2. Create two Subs: Save_State and Restore_State. First one (Save_State) - would save required values in variables defined in Process_Globals, Second one (Restore_State) - would restore them.
    3. Then add following code Activity_Pause Sub : Save_State - to save state of application each time when this function called i.e. when for example device rotated.
    4. And last step was to add following statement to Activity_Create:
    Code:
    If FirstTime <> True AND stSaved <> False Then
         
    'Log("Restore_state called from Activity_Create")
            Restore_State
    End If
    stState is a small Boolean type flag - that I use to check if Save_Stated function was already executed previously....

    It seems to work O.K. - but I would like just to crosscheck - how "correct" is such method.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  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