Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String SHARED_PREF_CACHED_KEY = "cache_file_name"; private static final String CACHE_FILENAME = "jsonCacheFile"; /** * Saves the name of the cache file in the SharePreferences when cached; * used to check later if there is cache */ public static void markJsonWasCached(Activity activity) { SharedPreferences.Editor sharedPrefEditor = activity.getPreferences(Context.MODE_PRIVATE).edit(); sharedPrefEditor.putString(SHARED_PREF_CACHED_KEY, CACHE_FILENAME); sharedPrefEditor.apply(); } }