Ahmed Faisal
Ahmed Faisal

Reputation: 4427

How to save user log-in state in Android?

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.

Upvotes: 15

Views: 16040

Answers (2)

Torid
Torid

Reputation: 4196

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.

Upvotes: 8

Asish AP
Asish AP

Reputation: 4441

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

Upvotes: 19

Related Questions