i want to get text written in the EditText first activity and set that text to the another EditText which is fourth activity.
            Asked
            
        
        
            Active
            
        
            Viewed 1,016 times
        
    0
            
            
        - 
                    [SharedPreferences](http://developer.android.com/guide/topics/data/data-storage.html#pref) will be the answer here. – Shrikant Ballal Jun 28 '12 at 11:51
- 
                    See my updated answer and comment on your accepted answer :) – RPB Jun 28 '12 at 12:20
- 
                    u can set the value of the edittext in a global variable then acess it in the Fourth activity – c2dm Jun 28 '12 at 11:53
4 Answers
1
            
            
        Simple way to do is, You can assign one static variable which is public inside first activity like,
public static String myEditTextContent;
Set this after you set the value from your edit text like,
myEditTextContent = editText.getText().toString();
Use the same in fourth activity like
FirstActivityClass.myEditTextContent and set it in this(fourth) activity.
Later on you can use intent's putExtra,SQLLite Database,Shared Preference also, as suggested by others
 
    
    
        RPB
        
- 16,006
- 16
- 55
- 79
1
            Use this code in your first activity
Intent intent = new Intent(context,Viewnotification.class);
          intent.putExtra("Value1", youredittextvalue.getText().toString());
startActiviy(intent);
And in your fourth Activity
Bundle extras = getIntent().getExtras();
        String value1 = extras.getString("Value1");
yourfourthactivityedittext.setText(value1);
 
    
    
        Shalini
        
- 1,733
- 4
- 17
- 31
- 
                    1Its not necessary that he will directly open fourth activity from first directly what is he opens Second and third activity in between and goes to fourth that time this will fail. :( – RPB Jun 28 '12 at 12:16
- 
                    @ Rinalkumar But he has not declare in question as move from first-second-third-fourth activities. – Shalini Jun 29 '12 at 05:39
- 
                    But what if it happens so this should be generic solution which should work in any case :) – RPB Jun 29 '12 at 05:56
0
            
            
        You can do it in two ways
First Use SharedPreferences like
// declare
SharedPreferences pref;
    SharedPreferences.Editor edit;
in On create
//initialize
                pref = this.getSharedPreferences("myPrefs", MODE_PRIVATE);
        edit = pref.edit();
// add data in it
edit.putString("USERNAME", EditText1.getText().toString());
edit.putString("PASSWORD", EditText1.getText().toString());
edit.putString("USERID",   Text1.getText().toString());
// save data in it
edit.commit();
to get data
// access it 
String passwrd = pref.getString("PASSWORD", "");
String userid = pref.getString("USERID", "");
And the second way
Send data from 1 to 2 and 2 to 3 and 3 to 4 activity 
with intents like
    Intent i = new Intent(First.this, Secondclass.class);
                    i.putExtra("userid", EditText1.getText().toString());
                    i.putExtra("username",EditText2.getText().toString());
                    startActivity(i);
and recieve in each activity like
       Intent i = getIntent();
     String   ursid = i.getStringExtra("userid");
 String   ursername = i.getStringExtra("username");
 
    
    
        Avi Kumar
        
- 4,403
- 8
- 36
- 67
 
     
    