You can user SharedPreferences
to save the information, so the second time the user accesses your application you check if this information is filled and log in automatically.
Example to save information using SharedPreferences
:
public static final String NOME_PREFERENCE = "INFORMACOES_LOGIN_AUTOMATICO";
SharedPreferences.Editor editor = getSharedPreferences(NOME_PREFERENCE, MODE_PRIVATE).edit();
editor.putString("login", "usuario01");
editor.putString("senha", "1234");
editor.commit();
And for you to recover this saved information:
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String login= prefs.getString("login", null);
String senha= prefs.getString("senha", null);
if (login!= null) {
// existe configuração salvar
} else {
// não existe configuração salvar
}
Kebler, my suggestion is to use
SharedPreferences
. It already has a standard security, but you can even encrypt if necessary. But the ideal is to save atoken
not a password. Have a look at the questions in the tag: http://answall.com/questions/tagged/sharedpreferences– Wakim
I am just in this part of my project, I am creating a token, for now I put together the login and encryption information, and saved using sharedpreferences. In my case I am doing SSL/TLS communication via socket , and every time the communication starts I send the token so the server can recognize the client.
– Skywalker
If your communication is via http, I think every request you should send the token or else work with cookies can help, but I don’t know if it would be safe.
– Skywalker
for your greater safety let the Sharedpreference private, [Activity.MODE_PRIVATE]
– FlipNovid