2

Possible Duplicate:
Passing data between activities in Android

How can I edit text in my Activity, then pass this text by an intent to a new Activity?

Community
  • 1
  • 1
Joja Ingy
  • 709
  • 1
  • 7
  • 8
  • Possible duplicates: http://stackoverflow.com/questions/2965109/passing-data-between-activities-in-android , http://stackoverflow.com/questions/5643243/passing-data-between-activities – Aleadam Apr 13 '11 at 22:05

1 Answers1

6

You can pass extra data via the intent using intent.putExtra("key", text_field.getText().toString()) on the intent before you send it (in the first activity) and getIntent().getExtras().getString("key") in the second activity.

This is assuming text_field is your EditText you want to pass the value from. You can change "key" to whatever you want, too.

Håvard
  • 9,900
  • 1
  • 41
  • 46
  • fine i will do it now !! but how can i save an text i edit it in one activity For example !! i want to Enter my name then in edit text field i want to write my name then it will be saved ?!!! can this happen ? – Joja Ingy Apr 13 '11 at 21:40
  • @Joja Ingy, if I understand you correctly, take a look at [data storage](http://developer.android.com/guide/topics/data/data-storage.html). – Håvard Apr 14 '11 at 16:39
  • String FILENAME = "hello_file"; String string = "hello world!"; FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.write(string.getBytes()); fos.close(); – Joja Ingy Apr 14 '11 at 19:56
  • where can i put it !! or implement the data storage in my code – Joja Ingy Apr 14 '11 at 19:57
  • 1
    @Joja it is clear why: there are other questions dealing with the same issue, so look at the those answers and you'll get yours. To avoid getting qustions closed, please search SO before posting a question. – Aleadam Apr 16 '11 at 18:12