15

I'm trying to build an app with a login module. I want to save the user login state so that the end-user will not have to retype his/her credentials except if they have explicitly logged out.

I understand that SharedPreferences can be of some use but I would appreciate it if some one can provide me some of their expert insight in this matter.

user
  • 86,916
  • 18
  • 197
  • 190
Ahmed Faisal
  • 4,397
  • 12
  • 45
  • 74

2 Answers2

19

use the below link.There is 3 way to store you login details . one is using shared preference and 2nd one way is store in a file and the third one is using sqlite. This will give you the ideas for storing login details.

save user data

Asish AP
  • 4,421
  • 2
  • 28
  • 50
8

You can use any of the three methods that Asish AP references. But for a small amount of data (one user's username, password, login state) SharedPreferences is probably the lightest / easiest.

But whichever way you go, you should make sure that you encrypt whatever you store using one of the Java encryption methods at Encrypt Password in Configuration Files?. Having plaintext credentials sitting around (eg on the SD card) is just way too vulnerable.

Community
  • 1
  • 1
Torid
  • 4,176
  • 1
  • 28
  • 29
  • Thank you for the suggestion. I guess, I will just proceed with saving the userId and let the user enter the password when required. – Ahmed Faisal Aug 02 '11 at 15:22