Having written couple of little apps I realized now - reading through the activity lifecycle docs several times again http://developer.android.com/reference/android/app/Activity.html - that there are good guidelines on how to structure activities which I haven't followed.
I would just like to get clarity around this in cases of user screen activities that work with DB values.
Is this the best recommended way to structure activities that require user interaction in combination with DB usage
?
1. onCreate()
- setContentView
- get and set the fixed UI elements such as x = findViewById
- set the setOnClickListeners and other Listeners
- any other stable/unchanged elements of the activity
2. onResume()
- since its also called AFTER EACH onCreate...
- open DB here
- get values from DB
- fill the user fields with DB dependant values
- configure the screen elements which depend on DB values as opposed to those that are stable
3 . onPause()
- finish all DB updates ensuring consistent DBs
- save all user created data that is required when activity resumes again
- close DB
Certainly this is not black and white, but do I understand it correctly that this is a general design principle in such cases so the activity is stable and reliable to interruptions such as phone calls, low memory situations, etc...
Many thanks four your input!