mWeatherData gets re-initialised to null each time onCreateLoader is executed since it resides within the anonymous class that gets created afresh each time.
This defeats the point of the Caching lessons, since it doesn't actually reuse the cached result when the user presses refresh.
Moving mWeatherData to be a member variable of the MainActivity class would resolve that issue.
app/src/main/java/com/example/android/sunshine/MainActivity.java
mWeatherData
gets re-initialised tonull
each time onCreateLoader is executed since it resides within the anonymous class that gets created afresh each time. This defeats the point of the Caching lessons, since it doesn't actually reuse the cached result when the user presses refresh. MovingmWeatherData
to be a member variable of the MainActivity class would resolve that issue.