While using Intent object we can put different types of data directly using its putExtra()
. We can also put these extra data into a Bundle
object and add it to Intent
. So why do we need Bundle
if we can do so using Intent
directly?
As you can see, the Intent
internally stores it in a Bundle
.
public Intent putExtra(String name, String value) {
if (mExtras == null) {
mExtras = new Bundle();
}
mExtras.putString(name, value);
return this;
}
Sometimes you need to pass only a few variables
or values
to some Other Activity
, but what if you have a bunch of variable's or values
that you need to pass to various Activities
. In that case you can use Bundle
and pass the Bundle
to the required Activity
with ease. Instead of passing single variable's every time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With