@@ -0,0 +1,3278 @@
+package com.alwaysallthetime.adnlibutils;%0A%0Aimport android.content.SharedPreferences;%0Aimport android.preference.PreferenceManager;%0A%0Aimport com.alwaysallthetime.adnlib.data.Configuration;%0Aimport com.alwaysallthetime.adnlib.data.Token;%0Aimport com.alwaysallthetime.adnlib.data.User;%0Aimport com.alwaysallthetime.adnlib.gson.AppDotNetGson;%0Aimport com.google.gson.Gson;%0A%0Aimport java.util.Date;%0A%0Apublic class ADNSharedPreferences %7B%0A    private static final String ACCESS_TOKEN = %22accessToken%22;%0A    private static final String TOKEN_OBJECT = %22tokenObject%22;%0A    private static final String CONFIGURATION_OBJECT = %22configurationObject%22;%0A    private static final String CONFIGURATION_DATE = %22configurationDate%22;%0A    private static final String USER_OBJECT = %22user%22;%0A%0A    private static SharedPreferences sPrefs;%0A    private static Gson gson;%0A%0A    static %7B%0A        sPrefs = PreferenceManager.getDefaultSharedPreferences(ADNApplication.getContext());%0A        gson = AppDotNetGson.getPersistenceInstance();%0A    %7D%0A%0A    public static boolean isLoggedIn() %7B%0A        return getAccessToken() != null;%0A    %7D%0A%0A    public static String getAccessToken() %7B%0A        return sPrefs.getString(ACCESS_TOKEN, null);%0A    %7D%0A%0A    public static Token getToken() %7B%0A        final String tokenJson = sPrefs.getString(TOKEN_OBJECT, null);%0A        return gson.fromJson(tokenJson, Token.class);%0A    %7D%0A%0A    public static void saveCredentials(String accessToken, Token token) %7B%0A        final SharedPreferences.Editor editor = sPrefs.edit();%0A        final String tokenJson = gson.toJson(token);%0A        editor.putString(TOKEN_OBJECT, tokenJson);%0A        editor.putString(ACCESS_TOKEN, accessToken);%0A        editor.commit();%0A    %7D%0A%0A    public static void clearCredentials() %7B%0A        final SharedPreferences.Editor editor = sPrefs.edit();%0A        editor.remove(TOKEN_OBJECT);%0A        editor.remove(ACCESS_TOKEN);%0A        editor.commit();%0A    %7D%0A%0A    public static Configuration getConfiguration() %7B%0A        final String configurationJson = sPrefs.getString(CONFIGURATION_OBJECT, null);%0A        if(configurationJson != null) %7B%0A            return gson.fromJson(configurationJson, Configuration.class);%0A        %7D%0A        return null;%0A    %7D%0A%0A    public static Date getConfigurationSaveDate() %7B%0A        final long configTime = sPrefs.getLong(CONFIGURATION_DATE, 0);%0A        if(configTime != 0) %7B%0A            return new Date(configTime);%0A        %7D%0A        return null;%0A    %7D%0A%0A    public static void saveConfiguration(Configuration configuration) %7B%0A        final SharedPreferences.Editor editor = sPrefs.edit();%0A        final String configJson = gson.toJson(configuration);%0A        editor.putString(CONFIGURATION_OBJECT, configJson);%0A        editor.putLong(CONFIGURATION_DATE, new Date().getTime());%0A        editor.commit();%0A    %7D%0A%0A    public static User getUser(String userId) %7B%0A        final String json = sPrefs.getString(USER_OBJECT + %22_%22 + userId, null);%0A        if(json != null) %7B%0A            return gson.fromJson(json, User.class);%0A        %7D%0A        return null;%0A    %7D%0A%0A    public static void saveUser(User user) %7B%0A        final SharedPreferences.Editor editor = sPrefs.edit();%0A        final String json = gson.toJson(user);%0A        editor.putString(USER_OBJECT + %22_%22 + user.getId(), json);%0A        editor.commit();%0A    %7D%0A%7D%0A

add preferences class for commonly persisted stuff.