SharedPreferences not saving in some Android versions
<p>Following is the code I used to save <code>SharedPreference</code>:</p>

<pre><code>SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = preferences.edit();

editor.putString("deliveryId", obj.get("deliveryId").toString());
editor.commit();
</code></pre>

<p>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.</p>

<p>Following is the code I used to get the data:</p>

<pre><code>SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String deliveryId = preferences.getString("deliveryId", "0");
</code></pre>

<p>Always gives the default value, i.e. <code>0</code>, on some devices.</p>