I am new to Android. Can you tell me what is a Bundle and how they are used in android?
-
1I think You better google it then you'll get your answer – Gouse Shaik Oct 24 '11 at 12:35
-
12@Gouse Sometimes a focused question can deliver focused highlights and pointers better than a Google search. +1 to the OP. – Bill The Ape Jan 06 '12 at 19:44
-
Go here http://stackoverflow.com/questions/4999991/what-is-a-bundle-in-an-android-application/30919826#30919826 – Ajay Takur Jun 18 '15 at 15:38
4 Answers
Bundle generally use for passing data between various Activities. It depends on you what type of values you want to pass but bundle can hold all types of values and pass to the new activity.
You can use it like ...
Intent intent = new
Intent(getApplicationContext(),SecondActivity.class);
intent.putExtra("myKey",AnyValue);
startActivity(intent);
Now you can get the passed values by...
Bundle extras = intent.getExtras();
String tmp = extras.getString("myKey");
you can also find more info on android-using-bundle-for-sharing-variables and Passing-Bundles-Around-Activities
Copy from Here.
Read this:
http://developer.android.com/reference/android/os/Bundle.html
It can be used to pass data between different Activity
's

- 98,571
- 55
- 246
- 278
The Android developer reference overview states:
A mapping from String values to various Parcelable types.
IOW, a Bundle is a set of key/value pairs, where it implements an interface called Parcelable.
Unlike a C++ map, which is also a container of key/value pairs but all values are of the same type, a Bundle can contain values of different types.

- 3,261
- 25
- 44