Android Guides | Samples

Android.App.FragmentManager.SaveFragmentInstanceState Method

Save the current instance state of the given Fragment.

Syntax

[Android.Runtime.Register("saveFragmentInstanceState", "(Landroid/app/Fragment;)Landroid/app/Fragment$SavedState;", "GetSaveFragmentInstanceState_Landroid_app_Fragment_Handler")]
public abstract Fragment+SavedState SaveFragmentInstanceState (Fragment f)

Parameters

f
The Fragment whose state is to be saved.

Remarks

Save the current instance state of the given Fragment. This can be used later when creating a new instance of the Fragment and adding it to the fragment manager, to have it create itself to match the current state returned here. Note that there are limits on how this can be used:

  • The Fragment must currently be attached to the FragmentManager.
  • A new Fragment created using this saved state must be the same class type as the Fragment it was created from.
  • The saved state can not contain dependencies on other fragments -- that is it can't use FragmentManager.PutFragment(Bundle,String,String) to store a fragment reference because that reference may not be valid when this saved state is later used. Likewise the Fragment's target and result code are not included in this state.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 13