I have three activities. In one Activity
, I read data from CSV
file and using ListView
, I am showing it in EditText
. Now, I want to pass value of EditText
to another Activity
. What can be done to solve this problem?
Code:
String dir = Environment.getExternalStorageDirectory() + "/grocery/data/" + spinner.toString();
final File csvfile = new File(dir.toString());
ListView listView = (ListView) findViewById(R.id.listview);
MyList adapter = new MyList(getApplicationContext(), R.layout.activity_editfeild);
listView.setAdapter(adapter);
studentid= (EditText) findViewById(R.id.et_studentid);
Schoolname= (EditText) findViewById(R.id.et_schoolname);
schoolAdress= (EditText) findViewById(R.id.et_schooladd);
studentname=(EditText) findViewById(R.id.et_studentname);
fathername= (EditText) findViewById(R.id.et_fathername);
mothername= (EditText) findViewById(R.id.et_mothername);
studentaddress= (EditText) findViewById(R.id.et_studentadd);
//Toast.makeText(Editinfo.this, studentid.getText().toString(), Toast.LENGTH_SHORT).show();
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(csvfile);
} catch (FileNotFoundException e){
e.printStackTrace();
}
CSVReader reader = new CSVReader(inputStream);
final List<String[]> myList=reader.read();
for (String[] data : myList) {
adapter.add(data);
}
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Editinfo1.class);
intent.putExtra("spinner", chosenOption);
intent.putExtra("studentid", studentid.getText().toString());
intent.putExtra("schoolname", Schoolname.getText().toString());
intent.putExtra("schooladdress", schoolAdress.getText().toString());
intent.putExtra("studentname", studentname.getText().toString());
intent.putExtra("fathername", fathername.getText().toString());
intent.putExtra("mothername", mothername.getText().toString());
intent.putExtra("studentaddress", studentaddress.getText().toString());
intent.putExtra("myList", (Serializable) myList);
//intent.putExtra("mylist", myList);
startActivity(intent);
}
});
}