Android Question Save fields values/state while rotating device


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:
If FirstTime <> True AND stSaved <> False Then
     'Log("Restore_state called from Activity_Create")
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.