Sena
Sena

Reputation: 298

Android Studio - How do I store user ID safely in SharedPreferences for user session?

I'm still learning Android, including its concepts. Currently I'm creating a login system. When someone enter correct username and password, the application will store user's ID in the SharedPreferences.

What I don't want is, someone tries to edit the "currentUserID" session with any user ID so he can instantly logged in. In PHP, I can store user ID inside $_SESSION and I think it's safe which no one can see inside and no one can edit it.

So how about the security of SharedPreferences? I've already googled and found that anything with root privileges are able to access it.

Sorry if there's anything wrong. Thanks.

Upvotes: 2

Views: 324

Answers (1)

shubhamgarg1
shubhamgarg1

Reputation: 1995

You can take look at https://developer.android.com/reference/android/accounts/AccountManager which will help you.

Upvotes: 1

Related Questions