Search code examples
androidandroid-activityback-buttondestroy

Is it possible to save previous activity?


My Android Application has only one activity called MainActivity. When I press the back-button and run my application again, the previous activity will be destroyed. Now I want to know that is it possible to save the exact previous activity?

Thank you


Solution

  • Pressing the back key kills your current activity. A user would not expect it to be saved as there is no way to go "Forward" .

    You can save the important parts of your activity in SharedPreferences or a database when you press back and restore it to its previous state when the activity next starts which would give the impression that it was "saved"