I have more than 3 edittext. When i enter something inside edittext i need to save this to another screen. I referred some question got answer. But how to pass through array. I used separate putExtra method of each edittext and another screen i need to display one TextView. Now i created separate TextView for each.
code:
Activity:
et=(EditText)findViewById(R.id.et);
et1=(EditText)findViewById(R.id.et1);
btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Save.this, Get.class);
String[] myStrings = new String[] {"et.getText().toString()", "et1.getText().toString()"};
intent.putExtra("strings", myStrings);
startActivity(intent);
SharedPreferences preferences = getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("Name","test");
editor.commit();
}
});
Activity1:
Intent intent = getIntent();
String[] myStrings = intent.getStringArrayExtra("strings");
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String name = preferences.getString("Name","");
txt=(TextView)findViewById(R.id.txt);
txt.setText(myStrings);