0

I am trying to differentiate between 2 user id's using sharedpreferences so preferences saved by one should not be seen by the other logging on the same device. I plan on doing something liek this: Sharedpreferences.java

public boolean isDifferentUser() {
        return mSharedPreferences.getBoolean(ISDIFFERENTUSER, false);
    }

I want to see if I can apply some sort of logic such that if(isdifferentuser){ dont save preferences } but I dont know how to differentiate between 2 users. They have 2 different user id's stored in database, how do I go about it? Any pointers?

Thanks!

  • Taking in consideration that preferences aren't really that good for sensitive information(which I'm assuming it's not the case) why not include the id of the user directly in the key names of the preferences? – user Oct 09 '14 at 17:15
  • Your question is so confusing. Can you be more specific?. – Harsha Oct 09 '14 at 17:18
  • Luksprog means something like this: return mSharedPreferences.getBoolean(STRINGKEY+"username" false); so that the key you use to s tore and retrieve data in shared preferences is differentiated by user – Martin Oct 09 '14 at 18:01

0 Answers0