1

In web development we have usually seen we use session or cookies to maintain username, and it remains there unless we destroy it or server removes it, i am making an android application, i have a login and a password, what i want is to just, if i get logged in, it should save my username in something similar to session or cookie, and if i move anywhere among intents or screens, it should not be destroyed and i must be able to access it any where. What's the best approach to implement it?

Muhammad Atif Agha
  • 1,535
  • 3
  • 33
  • 74

3 Answers3

4

store your username & password or session id in SharedPreferences on success

Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54
2

It depends how permanently persisted you want to store the information. If you need it to be remembered after the app is closed you'll need a persitant store but you should ensure that the password is encrypted.

If it's only for the running life of the app you could hold the information in static properties on a class.

simongking
  • 740
  • 5
  • 15
1

The best way is to store in in SharedPrefences. See this tutorial. Also use MD5 or SHA algorithm for encrypting. See this

Community
  • 1
  • 1
san
  • 1,845
  • 13
  • 23