Search code examples
androidpreferenceactivity

use preferenceactivity to store multiple value for a key for different profile


I use preferenceactivity to store different preference settings.In my application there can be more than one profile and for each profile I can set different types of settings in preferenceactivity's different key. But the problem is that when I made a change in a key in one profile it also reflect to others because it use same sharedpreference. Is there any way to use preferenceactivity with same key for each profile but it does not reflect to other profile,


Solution

  • Use a different sharedprefs file for each profile.

        context.getSharedPreferences("ProfileName", Context.MODE_PRIVATE);