Search code examples
androidandroid-fragmentsback-stack

Save state of the fragment backstack


What is the best way to save the state of the fragment backstack? Im having a problem when I open my application from the recent list, the order of the fragments is not the same as when I closed the application.

Any ideas on how to solve this?

Thanks!!


Solution

  • With fragmentTransaction.addToBackStack(NameYourFragment) you can't put the fragment in the backstack. When you want delete this fragment to the backstack you can use fragmentTransaction.popBackstack(). This methods and add, replace should be enough.

    Hope it helps you.