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 exist.
Reproduced on three devices.
Sample cases:
On first run, AAPL, FB, MSFT and YHOO are stored, then, we add A and B, app syncs correctly, if we swipe to refresh app syncs correctly too. Now we finish the activity and reopen Stock Hawk, app syncs, but only AAPL, FB, MSFT and YHOO are updated from Internet.
On first run, AAPL, FB, MSFT and YHOO are stored, then, we removed AAPL, if we swipe to refresh the behavior is the expected. Now we finish the activity and reopen Stock Hawk, app syncs, but ALL them AAPL, FB, MSFT and YHOO are updated from Internet.
Screen record (toast shows the updated symbols):
https://www.youtube.com/watch?v=8t31WMCwzpE
Possible approah:
From Android docs:
Note that you must not modify the set instance returned by this call. The consistency of the stored data is not guaranteed if you do, nor is your ability to modify the instance at all.
Maybe this is not relevant with the case, but replacing PrefUtils.js : editStockPref : 2 seems to fix the entire problem.
Set<String> stocks = getStocks(context);
to
Set<String> stocks = new HashSet<>(getStocks(context));