1) You can share int
with other activity like this :
String YOUR_KEY = "id";
Intent intent = new Intent(getApplicationContext(), DisplayContact.class);
intent.putExtra(YOUR_KEY, id);
startActivity(intent);
or
Bundle dataBundle = new Bundle();
dataBundle.putInt(YOUR_KEY, id);
intent.putExtras(dataBundle);
2) And get int
in your activity like that :
int defaultValue = 0;
int id = getIntent().getIntExtra(YOUR_KEY, defaultValue);
or
Bundle extras = getIntent().getExtras();
int id = extras.getInt(YOUR_KEY);
2
solved Bundle.putInt() , how does it work?