Get all fragments from backstack in order

10,305

Using the getBackStackEntryCount() you can iterate through the back stack and use the getBackStackEntryAt() method to get each Fragment.

EDIT: Based on some discussions in the comments, it is advised that you manually store a list of the Fragments you have added to your backstack, and persist these into your SharedPreferences. You can then read this list back when the application starts, and reload these fragments.

Share:
10,305
Leem.fin
Author by

Leem.fin

A newbie in software development.

Updated on June 04, 2022

Comments

  • Leem.fin
    Leem.fin almost 2 years

    I am using Fragments in my app project. All the fragments are added to back stack:

    ...
    fragmentTransaction.addToBackStack(null);
    ...
    

    Later on, what is the correct way to get all fragments from back stack in order ?