I have three fragments A,B,C In fragment A - a get some variable id, from server then i create bundle , put id in it and start fragment B, in this fragment i get id from bundle and display all information by this id on display, but when i start fragment C and then i press button back and return ti fragment B, variable id is null. How can i solve it? I think i can save id in Database,but maybe there is easier way? i understand that when i press back in fragment C, fragment B want to get information from bundle, thats why i make next:
Bundle bundle = getArguments();
if (fakeID == null) {
fakeID = bundle.getString("fakeID");
}
Edited:
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState == null)
{
Bundle bundle = getArguments();
fakeID = bundle.getString("fakeID");
}
else{
fakeID = savedInstanceState.getString("fakeID");
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
outState.putString("fakeID", fakeID);
}
But when i return to this fragment savedInstanceState == null in this statement
if (savedInstanceState == null)