Android - SharedPreference.getBoolean Retrieving False Even If I Am Storing True?
I am using SharedPreference to store the state of checkboxes but even i am storing true in it , its still retrieving false. Here is my code - @Override public void onPause() {
Solution 1:
You never call commit() on your editor I think :)
Try this:
public void saveState()
{
SharedPreferences sp = getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
for(int i = 0; i < itemCheck.length; i++)
{
Boolean b = itemCheck[i];
Log.e(TAG, b.toString());
editor.putBoolean(i+"", itemCheck[i]);
}
editor.commit();
}
Solution 2:
use editor.commit() after editor.putBoolean(i+"", itemCheck[i]);
Post a Comment for "Android - SharedPreference.getBoolean Retrieving False Even If I Am Storing True?"