tags:

views:

23

answers:

1

Currently, I'm using the following code across all of my activities in my app to store application level variables and carry values between activities..

prefs = this.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);

I didn't have a PreferenceActivity prior to this, but now I do and I am looking to store a few user prefs from this new PreferenceActivity in the same sharedPreferences tag, "MyPrefs".

I know I can access the PreferenceActivity SharedPrefs from my activities via

prefs = PreferenceManager.getDefaultSharedPreferences(this);

but I would like those values saved to my current sharedPreferences tag, "MyPrefs", but I'm not sure how to do this.

Thanks in advance..

A: 

You can't. the PreferneceManager always uses this.getPackageName () + "_preferences as preference name. Sorry to break the bad news. This is also important when you wish to use the new backup framework.

You can of course replace MyPrefs with this.getPackageName () + "_preferences.

Martin