JB08
JB08

Reputation: 41

Should we pass data in constructor or we should strictly stick to bundles to pass data from one fragment to another fragment?

I have seen usage of Fragment's constructor to pass data between the fragments(ex. new MyFragment(myData)) but I want to know if we should use that approach or not, the official google developer documentation mentions the usage of Bundle. I want to know what is the better approach and why? I am a beginner in android development so please feel free to guide. Thanks in advance!

Upvotes: 1

Views: 143

Answers (1)

Martin Zeitler
Martin Zeitler

Reputation: 76589

Pass Bundle as arguments, extract them onCreate() ...

then you can use them with the Navigation library, too.

Upvotes: 1

Related Questions