/* * Save the access token and expiry date so you don't have to fetch it each * time */ public static boolean save(Facebook session, Context context) { Editor editor = Preferences.getSharedPreferences(KEY).edit(); editor.putString(TOKEN, session.getAccessToken()); editor.putLong(EXPIRES, session.getAccessExpires()); editor.putLong(LAST_UPDATE, session.getLastAccessUpdate()); return editor.commit(); }
/* * Restore the access token and the expiry date from the shared preferences. */ public static boolean restore(Facebook session, Context context) { SharedPreferences savedSession = Preferences.getSharedPreferences(KEY); session.setTokenFromCache( savedSession.getString(TOKEN, null), savedSession.getLong(EXPIRES, 0), savedSession.getLong(LAST_UPDATE, 0)); return session.isSessionValid(); }
/** * clears facebook login credentials from the preferences * * @param context */ public static void clear(Context context) { Editor editor = Preferences.getSharedPreferences(KEY).edit(); editor.clear(); editor.commit(); }