Remember Me Function At Login
<p>I have two textbox and a checkmebox. But when i type my username and password and tick on the checkmebox, exit the application and go back again it doesn't appear. Why?</p>

<pre><code>// Get reference to UI elements
        txtLogin = (EditText) findViewById(R.id.txtLogin);
        txtPassword = (EditText) findViewById(R.id.txtPassword);

        SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);   
        String username = pref.getString(PREF_USERNAME, null);
        String password = pref.getString(PREF_PASSWORD, null);

        if (username == null || password == null) {
            //Prompt for username and password
            Toast.makeText(getBaseContext(),
                    "HI",
                    Toast.LENGTH_SHORT).show();
        }


        // Remember me function
        CheckBox cbRemember = (CheckBox) findViewById(R.id.chkRememberPassword);
        if (cbRemember.isChecked()) {

            getSharedPreferences(PREFS_NAME,MODE_PRIVATE)
            .edit()
            .putString(PREF_USERNAME, txtLogin.toString())
            .putString(PREF_PASSWORD, txtPassword.toString())
            .commit();
        }
</code></pre>
