diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/SettingsFile.java index 96f40c3296..dd4bbdfb66 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/SettingsFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/SettingsFile.java @@ -22,6 +22,32 @@ import java.util.HashMap; import java.util.Set; import java.util.TreeSet; +/** + * A HashMap that constructs a new SettingSection instead of returning null + * when getting a key not already in the map + */ +final class SettingsSectionMap extends HashMap +{ + @Override + public SettingSection get(Object key) + { + if (!(key instanceof String)) + { + return null; + } + + String stringKey = (String)key; + + if (!super.containsKey(stringKey)) + { + SettingSection section = new SettingSection(stringKey); + super.put(stringKey, section); + return section; + } + return super.get(key); + } +} + /** * Contains static methods for interacting with .ini files in which settings are stored. */ @@ -256,7 +282,7 @@ public final class SettingsFile */ public static HashMap readFile(final String fileName, SettingsActivityView view) { - HashMap sections = new HashMap<>(); + HashMap sections = new SettingsSectionMap(); File ini = getSettingsFile(fileName);