Hi everyone,

Almost everything is in the title. I am trying to save username and
password into the sharedpreferences file. I used the little function
below to do so:
Everything works (The data are written correctly, I can read them
afterward) but the editor.commit() always returns false even though
the commit works(). Is that a bug?

        private void saveCredential(String username, String password)
        {
                // Restore or Create preferences if it doesn't exist
                SharedPreferences settings = 
getSharedPreferences(Common.PREFS_NAME,
MODE_PRIVATE);
                // We need an Editor object to make changes in the preferences 
file
                SharedPreferences.Editor editor = settings.edit();
                // Then we add the login and the password
                editor.putString(Common.PREF_USERNAME,username);
                editor.putString(Common.PREF_PASSWORD,password);
                // We don't forget to commit our edits
                if (editor.commit())
                         Log.v(DEBUG_TAG, "(Username: " + username + ") ;
(password : " + password + ") correctly added into file " +
Common.PREFS_NAME);
               else
                       // not good
        }

If anyone has a solution, an answer, anything, that would be great ;)

Also in term of security, is that fine? Should I store the credential
into a database or anything else?

Thanks a lot.
Polo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to