Shared preferences issue
<p>I'm new to android development</p>

<p>In my application I want to keep log-in status of user in my activity. I have 2 edit boxes for entering name and password. And 1 check-box for user if he wants to keep log-in.</p>

<p>When user clicks on login button I'm saving name and password in shared preference. And in <code>onCreate</code> method I want to retrieve that value. If user has clicks check-box then he should directly redirect to next page. But its not working.</p>

<p>Here is my code:</p>

<pre><code>signUpButton=(Button)findViewById(R.id.signUpLoginId);          
signUpButton.setOnClickListener(this);

//toggleButtonOnOff=(ToggleButton)findViewById(R.id.togglebutton);

loginEditText = (EditText) findViewById(R.id.loginNameID);          
passwordEditText=(EditText)findViewById(R.id.passwordId);           
box=(CheckBox)findViewById(R.id.checkbox);

preferences=PreferenceManager.getDefaultSharedPreferences(context);

String n=preferences.getString(PREF_USERNAME, null);                
String p=preferences.getString(PREF_PASSWORD, null);

loginEditText.setText(n1);
passwordEditText.setText(p1);

Intent intent1=new Intent(LoginActivity.this,FindFishMenuActivity.class);                   
startActivity(intent1);

LoginActivity.this.finish();

if(box.isChecked())
{
    box.setChecked(true);
    Toast.makeText(LoginActivity.this,"box value set to true",Toast.LENGTH_LONG).show();
    password=passwordEditText.getText().toString();
    preferences=context.getSharedPreferences(key_str, MODE_PRIVATE);
    editor=preferences.edit();
    editor.putString(PREF_USERNAME, name);
    editor.putString(PREF_PASSWORD, password);
    editor.commit();
    intent=new Intent(LoginActivity.this,FindFishMenuActivity.class);
    startActivity(intent);
    LoginActivity.this.finish();
}
</code></pre>
