Android : Edit default shared preferences

on Thursday, December 4, 2014


Im having an issue with editing the DefaultSharedPreferences. Indded, I have a method that I call regularly and I would like to use its input to edit the default shared preferences.


Here is what I tried but doesn't seem to work:



mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(getString(R.string.pref_location_default), stringCoordinates);
editor.commit();


And here are my concerned Strings:



<!-- Key name for storing location in SharedPreferences [CHAR LIMIT=NONE] -->
<string name="pref_location_key" translatable="false">location</string>

<!-- Default postal code for location preference [CHAR LIMIT=NONE] -->
<string name="pref_location_default" translatable="false">-34.8799074,174.7565664</string>


Can someone help me please?


Thx!


0 comments:

Post a Comment