Reputation: 1226
Sometimes system can kill or terminate process of an activity. I need to save data of the activity to shared preferences.
Is any callback will call in this case?
onPause
or on onSaveInstanceState
not call.
Upvotes: 0
Views: 36
Reputation: 939
When the system kills an activity's process, callbacks like onPause(), onStop(), or even onSaveInstanceState() may not always be invoked, particularly in cases of abrupt termination (e.g., low memory). However, to handle such cases and ensure your data is saved to SharedPreferences, you can rely on the ViewModel and lifecycle-aware components like ProcessLifecycleOwner.
Upvotes: 0