A agb2008 Member Licensed User Longtime User Apr 23, 2015 #1 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: Define variables for required objects in Process_Globals Sub (of different types i.e. Double, Int, String, Boolean e.t.c.) 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. 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. And last step was to add following statement to Activity_Create: Code: Copy 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.
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: Define variables for required objects in Process_Globals Sub (of different types i.e. Double, Int, String, Boolean e.t.c.) 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. 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. And last step was to add following statement to Activity_Create: Code: Copy 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.
Erel B4X founder Staff member Licensed User Longtime User Apr 23, 2015 #2 You can use StateManager: StateManager - Helps managing Android applications settings and state Upvote 0