package fr.tvbarthel.apps.simpleweatherforcast.utils;


import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class SharedPreferenceUtils {
	private static String KEY_LAST_UPDATE = "SharedPreferenceUtils.Key.LastUpdate";
	private static String KEY_LAST_KNOWN_JSON_WEATHER = "SharedPreferenceUtils.Key.LastKnownJsonWeather";

	private static SharedPreferences getDefaultSharedPreferences(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context);
	}

	public static String getLastKnownWeather(final Context context) {
		return getDefaultSharedPreferences(context).getString(KEY_LAST_KNOWN_JSON_WEATHER, null);
	}

	public static long getLastUpdate(final Context context) {
		return getDefaultSharedPreferences(context).getLong(KEY_LAST_UPDATE, 0);
	}

	public static void storeWeather(final Context context, final String jsonWeather) {
		final Editor editor = getDefaultSharedPreferences(context).edit();
		editor.putString(KEY_LAST_KNOWN_JSON_WEATHER, jsonWeather);
		editor.putLong(KEY_LAST_UPDATE, System.currentTimeMillis());
		editor.apply();
	}

}

@@ -218,16 +218,66 @@
 nager;%0A%0A
+import fr.tvbarthel.apps.simpleweatherforcast.R;%0A%0A
 public c
@@ -488,16 +488,120 @@
 eather%22;
+%0A%09private static String KEY_TEMPERATURE_UNIT_SYMBOL = %22SharedPreferenceUtils.Key.TemperatureUnitSymbol%22;
 %0A%0A%09priva
@@ -1329,16 +1329,16 @@
 lis());%0A
-
 %09%09editor
@@ -1351,10 +1351,486 @@
 ();%0A%09%7D%0A%0A
+%09public static void storeTemperatureUnitSymbol(final Context context, final String unitSymbol) %7B%0A%09%09final Editor editor = getDefaultSharedPreferences(context).edit();%0A%09%09editor.putString(KEY_TEMPERATURE_UNIT_SYMBOL, unitSymbol);%0A%09%09editor.apply();%0A%09%7D%0A%0A%09public static String getTemperatureUnitSymbol(final Context context) %7B%0A%09%09return getDefaultSharedPreferences(context).getString(KEY_TEMPERATURE_UNIT_SYMBOL,%0A%09%09%09%09context.getString(R.string.temperature_unit_celsius_symbol));%0A%09%7D%0A%0A
 %7D%0A

Implement method to store and get the temperature unit