Reputation: 2504
I have a static Fragment with setRetainInstance(true)
inside an Activity, and this Fragment uses an Activity's member static variable.
I see that after an orientation change the value of that static variable is retained without need to saving it on Activity's onSaveInstanceState()
.
Can someone explain to me why? Thanks
Upvotes: 0
Views: 903
Reputation: 3274
Static
members belong to the class itself and not to the instances of that class. Check here for a simple example:
https://www.caveofprogramming.com/java/java-for-beginners-static-variables-what-are-they.html
Upvotes: 0