Hi all, I've been spending half a day trying to figure out why on earth my 
values are being "reset" instead of being saved through my shared 
preferences when I switch tabs.

First time when my app starts, if the user will click a button and then he 
will click another tab (another tab = another fragment), then saving values 
in my shared preferences will not work.
*If the user will go back to the main tab (the one the app starts with) and 
perform the same process again - it will work as it should.*
I even put in the first line of onPause() (right after I call 
super.onPause()) I've printed to LogCat the value I want to save to my 
shared prefs and it was the default value.
Also, I'm saving shared preferences in every one of the fragment's 
go-to-background lifecycles, just to be sure it's not me missing there.

I've done some experiments and I know it has to do with my tab listener's 
onTabUnselected method.

*
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (f != null) {
ft.detach(f);

}
}

if I remove the detach method, this will not happen and it will save my 
preferences correctly. But then of course every tab I will go to and back 
will show the same tab;

Please suggest what should I do, I'm really lost here.
Let me know if I should add more code so it will be easier to understand.


*

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to