title: How to save multiple data using shared preferences?
body: <p>I am making an app, wherein in this activity, I am trying to take data from the user and save it using shared preference.But the app crashes on click of the sign up button.
  <a href="https://i.stack.imgur.com/dD2MY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dD2MY.jpg" alt="enter image description here"></a></p>
  
  <p>Here is the SignUpActivity.java file -</p>
  
  <pre><code>package com.example.abinas.myapplication;
  
  import android.content.Context;
  import android.content.SharedPreferences; 
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText; 
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  
  public class SignUpActivity extends AppCompatActivity {
  
  private EditText e3;
  private EditText e4;
  private EditText e5;
  private EditText e6;
  private Button b2;
  private RadioGroup rg;
  private RadioButton rb;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_sign_up);
      rg = (RadioGroup)findViewById(R.id.radioroup);
      e3 = (EditText)findViewById(R.id.editText3);
      e4 = (EditText)findViewById(R.id.editText4);
      e5 = (EditText)findViewById(R.id.editText5);
      e6 = (EditText)findViewById(R.id.editText6);
      b2 = (Button)findViewById(R.id.button2);
      int selected_id = rg.getCheckedRadioButtonId();
      rb = (RadioButton)findViewById(selected_id);
  }
  
  public void onButtonClick(View view){
  
      final SharedPreferences pref;
      pref = getSharedPreferences("user_info",Context.MODE_PRIVATE);
      SharedPreferences.Editor edit = pref.edit();
      edit.putString("gender",rb.getText().toString());
      edit.putString("username",e4.getText().toString());
      edit.putString("name",e3.getText().toString());
      edit.putString("password",e5.getText().toString());
      edit.putInt("phone",Integer.parseInt(e6.getText().toString()));
      edit.apply();
      edit.commit();
      //b2.setText("SAVED");
      //b2.setClickable(false);
  }
  }
  </code></pre>
  
  <p>what changes should be done, to successfully save the data?</p>