Nothing better that with an example
Suppose you have two activities: Activity1 and Activity2 and you want to pass data beetwen then:
Activity1
private static final String MY_KEY = "My Key"
Intent intent = new Intent(Activity1.this, Activity2.class);
Bundle b = new Bundle();
b.putInt(MY_KEY, 112233);
intent.putExtras(b);
startActivity(intent);
Activity 2
private static final String MY_KEY = "My Key"
Bundle b = getIntent().getExtras();
int value = b.getInt(MY_KEY , 0);
//value now have the value 112233
What means "Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key." in this example?
Using Bundle you're sending the value 112233 from Activity 1 to Activity 2 using the key "MY_KEY". So, "MY_KEY" is associated with 112233.
As you can see there is a second parameter “0”.
It is the default value. In situation when Bundle doesn’t contains
data you will receive “0” (default value).