Skip to content

Instantly share code, notes, and snippets.

@isfaaghyth
Created October 1, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isfaaghyth/91d90aecf69af3448f23b83b29920462 to your computer and use it in GitHub Desktop.
Save isfaaghyth/91d90aecf69af3448f23b83b29920462 to your computer and use it in GitHub Desktop.
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import app.rangers.ranger.RangerApplication;
public class CacheManager {
private static final String TAG = "CacheManager";
private static SharedPreferences getPref() {
return PreferenceManager.getDefaultSharedPreferences(RangerApplication.getContext());
}
public static void save(String key, String value) {
Log.d(TAG, "saveCache: " + value);
getPref().edit().putString(key, value).apply();
}
public static String grab(String key) {
return getPref().getString(key, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment