From 7dfcfb6dca353157b40c2ff1fde36d2432f71fa4 Mon Sep 17 00:00:00 2001 From: Juande Martos Date: Tue, 4 Apr 2017 16:14:14 +0200 Subject: [PATCH] Applying possible solution for undesired behavior. When a stock symbol is added or removed, the change is applied immediately to the current view, however, when the app is restarted, none of the previous changes in stock list SharedPreference exist. Reported as issue #32 on StockHawk repository. "Symbol changes are not saving correctly to disk SharedPreferences" Read for details: https://github.com/udacity/StockHawk/issues/32 --- app/src/main/java/com/udacity/stockhawk/data/PrefUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/udacity/stockhawk/data/PrefUtils.java b/app/src/main/java/com/udacity/stockhawk/data/PrefUtils.java index 4e489b52..afab5fa9 100644 --- a/app/src/main/java/com/udacity/stockhawk/data/PrefUtils.java +++ b/app/src/main/java/com/udacity/stockhawk/data/PrefUtils.java @@ -39,7 +39,7 @@ public static Set getStocks(Context context) { private static void editStockPref(Context context, String symbol, Boolean add) { String key = context.getString(R.string.pref_stocks_key); - Set stocks = getStocks(context); + Set stocks = new HashSet<>(getStocks(context)); if (add) { stocks.add(symbol);