How to use remember me function in my android login application
<p>I am using the code for remember my username and password. i have tried a lot of hours for the code for remember my username name and password but i cant success in it.</p>

<p>Here is my code which i have download from internet but it didn't work for me.</p>

<p>I have declared this variable in the extends activity.</p>

<pre><code>    public static final String PREFS_NAME = "MyPrefsFile";
public static final String PREFS_USER = "prefsUsername";
public static final String PREFS_PASS = "prefsPassword";
</code></pre>

<p>after that I have also declare different variable like below.</p>

<pre><code>    public String PREFS_USERS;
public String PREFS_PASS;


String username;
String upass;
</code></pre>

<p>and in the click listener i have given the following code.</p>

<pre><code>    SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);   

                username = etUsername.getText().toString();
                upass = etPassword.getText().toString();

                getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
                .edit()
                .putString(PREFS_USERS, username)
                .putString(PREFS_PASS, upass)
                .commit();
</code></pre>

<p>and at the time at retry i have return the following code in the <code>oncreate</code> activity to retry my user name and password.</p>

<pre><code>     SharedPreferences pref = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

     username = pref.getString(PREFS_USERS, "");
     upass = pref.getString(PREFS_PASS, "");
</code></pre>

<p>But when I run the application i cant get the username and password.First time when i load the application i checked the remember me check box after log in and log out back from the application and close the application and when come back to it.it was not saved for me. </p>
