You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

STSDataAccess.java 808B

123456789101112131415161718192021222324252627282930
  1. package com.rthoni.stssaguenay.dataaccess;
  2. import android.content.Context;
  3. import android.content.SharedPreferences;
  4. /**
  5. * Created by robin on 10/1/16.
  6. */
  7. public class STSDataAccess {
  8. public static String SHARED_PREF_NAME = "sts-saguenay";
  9. public static String SHARED_PREF_FAVOURITE_STOPS = "favourites-stops";
  10. public static SharedPreferences getSharedPref(Context ctx)
  11. {
  12. return ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
  13. }
  14. public static String getFavouriteStopsJson(Context ctx)
  15. {
  16. return getSharedPref(ctx).getString(SHARED_PREF_FAVOURITE_STOPS, "[]");
  17. }
  18. public static void setFavouriteStopsJson(Context ctx, String str)
  19. {
  20. getSharedPref(ctx).edit().putString(SHARED_PREF_FAVOURITE_STOPS, str).apply();
  21. }
  22. }