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?
Asked
Active
Viewed 845 times
3 Answers
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