Robin Dijkhof
Robin Dijkhof

Reputation: 19288

Is the onSaveInstanceState Bundle the same for every activity?

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

Answers (1)

Hussein El Feky
Hussein El Feky

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

Related Questions