In this code I want to send firstname and middlename to another activity. But My problem is that without clicking any button I want to send these two values to the next activity.
Because in this activity, clicking on the send button, data should be passed to the next Activity, but the screen should not navigate to the next activity.
Now These Two values I want to access in some another class file.
Can any one please help me.
class
Send.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
String first_name = fname1.getText().toString();
String middle_name = mname1.getText().toString();
}
});
You can achieve this with SQLite
, Shared Preferences
or simply just by create a new public class with static
variables.
Create a new class :
public class Global {
public static String first_name = "";
public static String middle_name = "";
}
Change your code :
Send.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
Global.first_name = fname1.getText().toString();
Global.middle_name = mname1.getText().toString();
}
});