Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

[!] Symbol changes are not saving correctly to disk SharedPreferences #32

Open
bumxu opened this issue Apr 3, 2017 · 0 comments
Open

Comments

@bumxu
Copy link

bumxu commented Apr 3, 2017

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));
bumxu added a commit to bumxu/StockHawk that referenced this issue Apr 3, 2017
Symbol changes are not saving correctly to disk SharedPreferences.
bumxu added a commit to bumxu/StockHawk that referenced this issue Apr 12, 2017
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 udacity#32 on StockHawk repository.
"Symbol changes are not saving correctly to disk SharedPreferences"
Read for details: udacity#32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant