package com.rthoni.stssaguenay.dataaccess; import android.content.Context; import android.content.SharedPreferences; /** * Created by robin on 10/1/16. */ public class STSDataAccess { public static String SHARED_PREF_NAME = "sts-saguenay"; public static String SHARED_PREF_FAVOURITE_STOPS = "favourites-stops"; public static String SHARED_PREF_LOGGED_USER = "logged-user"; public static SharedPreferences getSharedPref(Context ctx) { return ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE); } public static String getFavouriteStopsJson(Context ctx) { return getSharedPref(ctx).getString(SHARED_PREF_FAVOURITE_STOPS, "[]"); } public static void setFavouriteStopsJson(Context ctx, String str) { getSharedPref(ctx).edit().putString(SHARED_PREF_FAVOURITE_STOPS, str).apply(); } public static String getLoggedUserJson(Context ctx) { return getSharedPref(ctx).getString(SHARED_PREF_LOGGED_USER, null); } public static void setLoggedUserJson(Context ctx, String str) { getSharedPref(ctx).edit().putString(SHARED_PREF_LOGGED_USER, str).apply(); } }