Answer the question
In order to leave comments, you need to log in
Does Android save app data when forced to unload?
Hey!
Everyone knows that an application in the background of Android can crash if, for example, there is not enough memory.
Question: after such a kill, when you open the application, does it try to restore its state? Or stupidly opens from scratch?
If it does, is there any way to save the state of the application (like onSaveInstanceState on an Activity)?
Answer the question
In order to leave comments, you need to log in
In general, depending on what is considered a state. If the activity is put in the background, onSaveInstanceState will be called, if the application is killed by the system, then when restoring from the list of recently opened ones, onRestoreInstanceState will be called. Accordingly, if you save everything you need, then it will be restored. This is approximately what happens with don't keep activities.
Any singletons, statics saved in the application, generally speaking, will be lost.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question