Getting Data From First Activity To Fourth Activity In Android
i want to get text written in the EditText first activity and set that text to the another EditText which is fourth activity.
Solution 1:
Use this code in your first activity
Intent intent = newIntent(context,Viewnotification.class);
intent.putExtra("Value1", youredittextvalue.getText().toString());
startActiviy(intent);
And in your fourth Activity
Bundleextras= getIntent().getExtras();
Stringvalue1= extras.getString("Value1");
yourfourthactivityedittext.setText(value1);
Solution 2:
Solution 3:
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
Solution 4:
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 Stringpasswrd= pref.getString("PASSWORD", "");
Stringuserid= 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
Intenti=newIntent(First.this, Secondclass.class);
i.putExtra("userid", EditText1.getText().toString());
i.putExtra("username",EditText2.getText().toString());
startActivity(i);
and recieve in each activity like
Intenti= getIntent();
Stringursid= i.getStringExtra("userid");
Stringursername= i.getStringExtra("username");
Post a Comment for "Getting Data From First Activity To Fourth Activity In Android"