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 SQLite
, I only able to see the values saved in WorkForce
table. I getting NULL
value in Information
table. Why would this happen? It is only able to pass the data to two activities only?
Information
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent intent = new Intent(context, WorkForce.class);
a = spinner.getSelectedItem().toString();
intent.putExtra("a",a);
startActivity(intent);
}
});
WorkForce
button.setOnClickListener
(
new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(context, WorkDetailsTable.class);
subCon=txt1.getText().toString();
startActivity(intent);
}
}
);
WorkDetailsTable
final String name=getIntent().getExtras().getString("a");
final String subContractors=getIntent().getExtras().getString("subCon");
Button btn1=(Button)findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
ts.insertTimeSheet(name);
WF.insertWorkForce(subContractors);
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 ofa
from intent in workforce and pass the same value in intent to workdetails.so your code for WorkForce would be like below.
It doesn't seem like you are passing the data using Intent while launching WorkDetailsTable. You probably want it to look like this:
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.