Search code examples
androidsecuritysharedpreferencesandroid-sharedpreferencesandroid-security

How to prevent SharedPreferences from being changed


I'm worried about android security. I am storing the user id in sharedpreferences. I see some programs online that allow you to get into the sharedpreferences if your device is rooted... etc...

How do I prevent my sharedpreferences from being changed?


Solution

  • There is no way to avoid a user being able to change shared prefs. You need to implement security on your back end with session tokens so that even if the front end userid is changed the back end doesn't allow you to make requests because the session token doesnt match the user id. I assume you are asking because you are having you app communicate with a server and dont want the user to be able to see other peoples data. if not may i ask why you need to be able to do this?

    read more about them here Session token - how does it work?