Example usage for android.content SharedPreferences getLong

List of usage examples for android.content SharedPreferences getLong

Introduction

In this page you can find the example usage for android.content SharedPreferences getLong.

Prototype

long getLong(String key, long defValue);

Source Link

Document

Retrieve a long value from the preferences.

Usage

From source file:Main.java

public static long getCacheTime(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Preference", 0);
    long cacheTime = settings.getLong("CacheTime", 0);
    return cacheTime;
}

From source file:Main.java

/**
 * get long preferences/* ww w  .j a v  a 2 s . com*/
 * 
 * @param context
 * @param key The name of the preference to retrieve
 * @param defaultValue Value to return if this preference does not exist
 * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
 *         this name that is not a long
 */
public static long getLong(Context context, String key, long defaultValue) {
    SharedPreferences settings = getDefaultPreferences(context);
    return settings.getLong(key, defaultValue);
}

From source file:Main.java

public static long getPreference(Context context, String key, long defaultValue) {
    SharedPreferences pref = getPreferences(context);
    return pref.getLong(key, defaultValue);
}

From source file:Main.java

public static Long getLongSPR(String key, Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getLong(key, Long.MAX_VALUE);
}

From source file:Main.java

public static long readLong(Context context, String key, long defaultValue) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    return pre.getLong(STORE_KEY_PREFIX + key, defaultValue);
}

From source file:Main.java

public static long getLong(Context context, final String key, final long defaultValue) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    return settings.getLong(key, defaultValue);
}

From source file:Main.java

public static long getPrefLong(Context context, final String key, final long defaultValue) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    return settings.getLong(key, defaultValue);
}

From source file:Main.java

public static long getLong(Context context, String key, long defaultValue) {
    try {//from w ww .j  a va2  s .c  o m
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
        return sp.getLong(key, defaultValue);
    } catch (Exception e) {
        e.printStackTrace();
        return defaultValue;
    }
}

From source file:Main.java

public static long getLong(Context context, String key) {

    SharedPreferences sp = context.getSharedPreferences("configdata", Context.MODE_PRIVATE);

    return sp.getLong(key, 0);
}

From source file:Main.java

public static long getNotificationTime(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(NOTIFICATION_TIME_SHARED, 0);
    return preferences.getLong(NOTIFICATION_TIME, 0);
}