dev90
dev90

Reputation: 7559

How to set bundle to null, once data is consumed

I am passing data from an activity to fragment by using following code.

    Bundle bundle= new Bundle();
    bundle.putString("seatId", seatId);
    fragment.setArguments(bundle);

Then I consume the data by using following code in my fragment.

Bundle args = getArguments();
    if(args!=null && args.getString("seatId")!=null){
        matchId = args.getString("seatId", "");
    }

Now after this I want to set bundle to null.

The issue is once I set data to fragment through bundle, it keeps it there.

Upvotes: 0

Views: 59

Answers (1)

Rodrigo Queiroz
Rodrigo Queiroz

Reputation: 2844

Get hold of the bundle or simply getArguments().clear() as stated here.

Upvotes: 1

Related Questions