Pass Data To Three Activities Using Intent
I have three activities and the flow should like Information>>workForce>>workDetailsTable. I pass the data by using intent. However, when I see the data stored in SQLit
Solution 1:
It doesn't seem like you are passing the data using Intent while launching WorkDetailsTable. You probably want it to look like this:
String name=getIntent().getExtras().getString("a");
button.setOnClickListener
(
newView.OnClickListener() {
publicvoidonClick(View v) {
Intent intent = newIntent(context, WorkDetailsTable.class);
subCon=txt1.getText().toString();
intent.putExtra("a",name);
intent.putExtra("subCon",subCon);
startActivity(intent);
}
}
);
But this is probably not the best way you want to do this. Have you considered using SharedPreferences instead? This would allow you to store information in one activity and retrieve in any other activity.
There's a good example here.
Solution 2:
you are not passing subCon
string through intent to workdetails table. pass them like you did in information activity. also you need to get value of a
from intent in workforce and pass the same value in intent to workdetails.
so your code for WorkForce would be like below.
button.setOnClickListener ( new View.OnClickListener() {
publicvoidonClick(View v) {
Intent intent = new Intent(context,WorkDetailsTable.class);
subCon=txt1.getText().toString();
intent.putExtra("a",getIntent().getExtras().getString("a"));
intent.putExtra("subCon",subCon);
startActivity(intent);
}
});
Post a Comment for "Pass Data To Three Activities Using Intent"