Following is the code I used to save SharedPreference
:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = preferences.edit();
editor.putString("deliveryId", obj.get("deliveryId").toString());
editor.commit();
This is not working in some devices, but working in some devices. It is working on KitKat but doesn't work on JellyBean and Lollipop.
Following is the code I used to get the data:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String deliveryId = preferences.getString("deliveryId", "0");
Always gives the default value, i.e. 0
, on some devices.