3

How can I handle a persistent login for my Android app? For instance, an app like facebook requires initial credentials from the user to login for the first time, but from then on requires no additional actions from the user. How is this achieved from the client Android app? Where should any persistent data be stored? Can this be cookies or should I write data to a database or even Internal Storage? Once the login has been established, should I just rely on server sessions to authenticate the user or should I send the cookie and/or username and password with every API call?

user123321
  • 12,593
  • 11
  • 52
  • 63
  • Did u get a good solution for this? The question if one should always send user/pass/cookie in each and every web service call? – Ted Oct 26 '11 at 18:27
  • yes, send a auth token in every web call. The service should be stateless which means you need to authenticate each time. – user123321 Jun 06 '13 at 21:05
  • possible duplicate of [Android: Storing username and password?](http://stackoverflow.com/questions/1925486/android-storing-username-and-password) – arkon Jul 31 '15 at 09:12

1 Answers1

0

You need to use SharedPreferences to achieve this.

Look here for examples on how to do it.

PravinCG
  • 7,688
  • 3
  • 30
  • 55
  • 1
    Is this secure? Storing a username and password in sharedPreferences makes me a little nervous to say the least – Richard Tingle Nov 27 '14 at 11:10
  • 1
    You don't need to store the username and password, simply storing whether the user is signed in or not will suffice ;) – Burrito Aug 12 '17 at 03:04