i think the question has more to do with why
PreferenceManager.getDefaultSharedPreferences(this).getAll()
is returning an empty/contradictory map than with how to iterate over a standard java map. the android doc isn't really crystal clear about what's going here but basically it seems like the first call ever to
PreferenceManager.setDefaultValues(this, R.xml.preferences,false)
-- which is what you're supposed to call to initialize preferences when you start your app -- creates some kind of cached version of your preferences which causes future changes to your xml preferences file to be inconsistently handled, i.e., causing the mismatch you described in your question.
to reset this "cached entity", follow these steps (which you can sort of come up with from the above link):
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().clear();
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);