From 3daf7cd24791ea713592929b8d48eb25c1c6f51d Mon Sep 17 00:00:00 2001 From: Pavol Zibrita Date: Mon, 2 Apr 2012 14:34:55 +0200 Subject: [PATCH] Catch possible exceptions when settings change. --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b82ecd9979..5e95408c29 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -8,6 +8,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.osmand.LogUtil; import net.osmand.Version; import net.osmand.access.AccessibleToast; import net.osmand.access.RelativeDirectionStyle; @@ -381,11 +382,16 @@ public class OsmandSettings { @Override protected E getValue(SharedPreferences prefs, E defaultValue) { - int i = prefs.getInt(getId(), -1); - if(i < 0 || i >= values.length){ - return defaultValue; + try { + int i = prefs.getInt(getId(), -1); + if(i < 0 || i >= values.length){ + return defaultValue; + } + return values[i]; + } catch (Exception e) { + android.util.Log.e(LogUtil.TAG, "Error getting value for: " + this.getId(), e); + return defaultValue; } - return values[i]; } @Override