Reputation: 19288
Assume I have 2 Fragments which both use the onSaveInstanceState Bundle. In both fragments I put two different strings with the same key. Do I lose one? Or is the Bundle a different instance for each activity/fragment?
Upvotes: 0
Views: 102
Reputation: 6707
Every activity/fragment has its own Bundle
, so you won't lose any saved data in your bundle.
Bundle
is just like any other object in android like (String, SharedPreferences, SQLiteDatabase, AnimationUtils, etc...), so you can declare it in your activity/fragment normally just like any other object. It is not a special thing like many people think; thus, every activity/fragment can has its own bundle that you declare (It is usually the default parameter declared in onCreate()
).
Upvotes: 1