i stored a list of data in sharedpreference which is only viewable by a particular user, however when i try to login another account i am still able to view the data.
Is it due to local development environment so that even if different user logged in we will still read the same sharedpreference file? Can i assume once the app go into production, the issue will be gone since the users should be using different machine?
If not, how can i achieve multiple sharedpreference for multiple user?
Thanks!
It's most likely due to the way that you are storing the data. Shared preferences depend on keys Strings
. If you are storing different users but using the same keyword for all of them, i.e user
, then it won't be unique.
Specify a unique key for every user, and easiest thing to do is use their email. When you store that data in your shared preferences, use this unique key for every user. This way you don't have data overlapping.