jerith
jerith

Reputation: 141

data transfer from one activity to another activity on button click event

i try to transfer data from one activity to another but i can't achieve it.. can any one assit me.. kindly assit with example... thanks in advance..

Upvotes: 1

Views: 2764

Answers (2)

amiekuser
amiekuser

Reputation: 1630

Only primitive data types like string, integers etc can be passed. Also you can pass ArrayList etc. Object cannot be passed. Following are a few lines of code to explain:

From the activity you want to send data

Intent intent = new Intent(this,NewActivity.class);
intent.putExtra("LABEL", <data>);

In the new activity:

Bundle bundle = getIntent().getExtras();
data = bundle.getInt("LABEL");

Upvotes: 2

svidnas
svidnas

Reputation: 581

Use Intent to transfer you data from Activity to another. Check out Android Developer | Intents and Intent Filters and Android Developer | Intent documentation

Upvotes: 0

Related Questions