title: Shared Preferences in android showing Default value not found
body: <p>I strucked in storing and getting shared preferences.When a user has been registered if that registration is success then that values has to be stored in his profile nothing but my profile class.I don't know why am getting default value please give me a suggestion.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Please tellmesomething Again I updated the code here.</p>
  
  <pre><code>  public class Register extends Activity  {
  
  
  /**
   * Defining layout items.
   **/
  
  EditText mFirstName, mLastName, mUsername, mMobile, mPassword;
  ImageView img_back;
  Button btnRegister, mbtnSignIn;
  TextView registerErrorMsg;
  String jsonresponce=null;
  String enteredUsername,enteredPassword,enteredfname,enteredlname,enteredmobile;
  String REGISTER_URL;
  ProgressDialog pd;
  private SharedPreferences sharedpreferences;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_register);
      mFirstName = (EditText) findViewById(R.id.fname);
      mLastName = (EditText) findViewById(R.id.lname);
      mUsername = (EditText) findViewById(R.id.username);
      mMobile = (EditText) findViewById(R.id.mobie);
      mPassword = (EditText) findViewById(R.id.pword);
      btnRegister = (Button) findViewById(R.id.register);
      mbtnSignIn = (Button) findViewById(R.id.signin);
      registerErrorMsg = (TextView) findViewById(R.id.tv);
      sharedpreferences = getSharedPreferences("a2a", Context.MODE_PRIVATE);
      img_back = (ImageView) findViewById(R.id.imageback);
  
      img_back.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Intent i_backtohome = new Intent(Register.this, HomeActivity.class);
              startActivity(i_backtohome);
          }
      });
      mbtnSignIn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent i_backtosignin = new Intent(Register.this, Signin.class);
              startActivity(i_backtosignin);
  
          }
      });
  
  
      btnRegister.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              enteredUsername = mUsername.getText().toString();
              Log.e("username",enteredUsername);
  
              enteredPassword = mPassword.getText().toString();
              Log.e("username",enteredPassword);
  
              enteredfname = mFirstName.getText().toString();
              Log.e("username",enteredfname);
  
              enteredlname = mLastName.getText().toString();
              Log.e("username",enteredlname);
  
              enteredmobile = mMobile.getText().toString();
              Log.e("username",enteredmobile);
  
              REGISTER_URL = "http://ffhhhjkhjgh/register.php?UserName="+enteredUsername+"&amp;FirstName="+enteredfname+"&amp;LastName="+enteredlname+"&amp;Mobile="+enteredmobile+"&amp;Pass="+enteredPassword;
  
              // REGISTER_URL = REGISTER_URL + enteredUsername + enteredPassword + enteredfname + enteredlname + enteredmobile;
              Log.e("finalurl",REGISTER_URL);
  
              if (enteredUsername.equals("") || enteredfname.equals("") || enteredlname.equals("")
                      || enteredmobile.equals("") || enteredPassword.equals("")) {
  
                  Toast.makeText(Register.this, "All Fields are Mandatory", Toast.LENGTH_LONG).show();
  
                  return;
              }
              if (mUsername.length() &lt;= 1 || mPassword.length() &lt;= 1) {
  
                  Toast.makeText(Register.this, "Username or password length must be greater than one", Toast.LENGTH_LONG).show();
  
                  return;
  
              }
              new AsyncDataClass().execute();
  
          }
      });
  }
  
    class AsyncDataClass extends AsyncTask&lt;String, String, String&gt; {
  
     /* String fName;
      String lName;
        public AsyncDataClass(){
          this.fName = enteredfname;
           this.lName = enteredlname;
        }*/
  
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pd = new ProgressDialog(Register.this);
            pd.setMessage("Loading...");
            pd.setCanceledOnTouchOutside(false);
            pd.show();
            }
  
        @Override
        protected String doInBackground(String... params) {
  
            try{
                URL url = new URL(REGISTER_URL);
                String res;
  
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  
                conn.setRequestMethod("POST");
                conn.setDoOutput(true);
                conn.setDoInput(true);
                conn.connect();
                res = conn.getResponseMessage();
                Log.e("res", res);
  
  
                InputStream in = conn.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
                StringBuilder sb = new StringBuilder();
                String line = null;
  
                try{
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }
                    in.close();
                    reader.close();
                    jsonresponce = sb.toString();
                    Log.e("jsondata", jsonresponce);
                }catch (Exception e) {
                    e.printStackTrace();
                }finally {
                    try {
                        conn.disconnect();
                    }
                    catch (Exception e) {
                        e.printStackTrace();
                    }
                }
  
            }catch (Exception e){
                e.printStackTrace();
            }
            return jsonresponce;
        }
  
        @Override
        protected void onPostExecute(String s) {
  
            pd.dismiss();
  
                  if("SUCCESS".equals(jsonresponce)){
                      Toast.makeText(getApplicationContext(),jsonresponce,Toast.LENGTH_SHORT).show();
                      SharedPreferences sharedpreferences = getApplicationContext().getSharedPreferences("a2a", Context.MODE_PRIVATE);
                      SharedPreferences.Editor editor = sharedpreferences.edit();
                      editor.putString("enteredfname", enteredfname);
                      editor.putString("enteredlname", enteredlname);
                      editor.commit();
                  }else{
                      Toast.makeText(getApplicationContext(),jsonresponce,Toast.LENGTH_SHORT).show();
                  }
  
            super.onPostExecute(s);
        }
    }
      }
  </code></pre>