title: Sending data to other activity using sharedpreferences android
body: <p>i found a tutorial on the internet for saving and loading text from the same text fields in the                                                                               same activity. but i want to load some of the data (<strong>Name</strong> and <strong>Age</strong>) in the Text Views of another activity. how do i do that</p>
  
  <pre><code>public class MainActivity extends Activity {
      SharedPreferences sharedpreferences;
      TextView name;
      TextView email;// age
      TextView gender;//weight
      TextView height;
      public static final String mypreference = "mypref";
      public static final String Name = "nameKey";
      public static final String Email = "emailKey";
      public static final String Gender = "genderKey";
      public static final String Height = "heightKey";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          name = (TextView) findViewById(R.id.etName);
          email = (TextView) findViewById(R.id.etEmail);
          gender = (TextView) findViewById(R.id.etGender);
          height = (TextView) findViewById(R.id.etHeight);
          sharedpreferences = getSharedPreferences(mypreference,
                  Context.MODE_PRIVATE);
          if (sharedpreferences.contains(Name)) {
              name.setText(sharedpreferences.getString(Name, ""));
          }
          if (sharedpreferences.contains(Email)) {
              email.setText(sharedpreferences.getString(Email, ""));
          }
          if (sharedpreferences.contains(Gender)) {
              gender.setText(sharedpreferences.getString(Gender, ""));
          }
          if (sharedpreferences.contains(Height)) {
              height.setText(sharedpreferences.getString(Height, ""));
  
          }
  
      }
  
      public void Save(View view) {
          String n = name.getText().toString();
          String e = email.getText().toString();
          String g = gender.getText().toString();
          String h = height.getText().toString();
          Editor editor = sharedpreferences.edit();
          editor.putString(Name, n);
          editor.putString(Email, e);
          editor.putString(Gender, g);
          editor.putString(Height, h);
          editor.commit();
      }
  
      public void clear(View view) {
          name = (TextView) findViewById(R.id.etName);
          email = (TextView) findViewById(R.id.etEmail);
          gender = (TextView) findViewById(R.id.etGender);
          height = (TextView) findViewById(R.id.etHeight);
          name.setText("");
          email.setText("");
          gender.setText("");
          height.setText("");
  
      }
  
      public void Get(View view) {
          name = (TextView) findViewById(R.id.etName);
          email = (TextView) findViewById(R.id.etEmail);
          gender = (TextView) findViewById(R.id.etGender);
          height = (TextView) findViewById(R.id.etHeight);
          sharedpreferences = getSharedPreferences(mypreference,
                  Context.MODE_PRIVATE);
  
          if (sharedpreferences.contains(Name)) {
              name.setText(sharedpreferences.getString(Name, ""));
          }
          if (sharedpreferences.contains(Email)) {
              email.setText(sharedpreferences.getString(Email, ""));
          }
          if (sharedpreferences.contains(Gender)) {
              gender.setText(sharedpreferences.getString(Gender, ""));
          }
          if (sharedpreferences.contains(Height)) {
              height.setText(sharedpreferences.getString(Height, ""));
  
          }
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>