/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Abhijit Parida <abhijitparida.me@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package app.abhijit.iter.data;

import android.content.SharedPreferences;

public class Cache {

    SharedPreferences mSharedPreferences;

    public Cache(SharedPreferences sharedPreferences) {
        mSharedPreferences = sharedPreferences;
    }
}

@@ -1225,35 +1225,305 @@
 content.
-SharedPreferences;%0A
+Context;%0Aimport android.content.SharedPreferences;%0Aimport android.preference.PreferenceManager;%0A%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.JsonSyntaxException;%0A%0Aimport app.abhijit.iter.models.Student;%0A%0A/**%0A * This class handles local storage and retrieval of Student objects.%0A */
 %0Apublic 
@@ -1541,16 +1541,24 @@
  %7B%0A%0A    
+private 
 SharedPr
@@ -1567,18 +1567,17 @@
 erences 
-mS
+s
 haredPre
@@ -1590,111 +1590,552 @@
 es;%0A
-%0A    public Cache(SharedPreferences sharedPreferences) %7B%0A        mSharedPreferences = sharedPreferences
+    private Gson gson;%0A%0A    public Cache(Context context) %7B%0A        this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);%0A        this.gson = new Gson();%0A    %7D%0A%0A    public Student getStudent() %7B%0A        try %7B%0A            return gson.fromJson(sharedPreferences.getString(%22student%22, null), Student.class);%0A        %7D catch (JsonSyntaxException e) %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    public void setStudent(Student student) %7B%0A        sharedPreferences.edit().putString(%22student%22, gson.toJson(student)).apply()
 ;%0A  

Implement Cache.getStudent() and Cache.setStudent()