Null handling for dictionary and SharedPreferences.