Example usage for android.content SharedPreferences getFloat

List of usage examples for android.content SharedPreferences getFloat

Introduction

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

Prototype

float getFloat(String key, float defValue);

Source Link

Document

Retrieve a float value from the preferences.

Usage

From source file:Main.java

/**
 * Retrieves a float value from preference manager. If no such key exists, it will return
 * <code>Float.MIN_VALUE</code>.
 *//* w  w  w .java  2 s. co m*/
public static float getFloatFromPreference(Context context, String key) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    return pref.getFloat(key, Float.MIN_VALUE);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static float getFloat(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE);
    float value;//from ww  w.j a  va 2s  .  c om
    value = sp.getFloat(key, -1F);
    return value;
}

From source file:Main.java

public static float getFloat(Context context, String key, float defValue) {
    SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    return sp.getFloat(key, defValue);
}

From source file:Main.java

public static float getPreference(String key, float defaultValue, Context c) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c);
    return preferences.getFloat(key, defaultValue);
}

From source file:Main.java

private static float getFloatPreference(Context context, String key) {
    float value = -1;
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    if (preferences != null) {
        value = preferences.getFloat(key, Float.MIN_VALUE);
    }//from   w  w w .  j  av  a 2s  . c  om
    return value;
}

From source file:Main.java

/**
 * get float preferences/*from w w  w.  ja  v  a  2s  . c  om*/
 *
 * @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 float
 */
public static float getFloat(Context context, String key, float defaultValue) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    return settings.getFloat(key, defaultValue);
}

From source file:Main.java

public static Double getDouble(Context context, String key) {
    double isi;/*w ww  . j a  v  a 2s  . com*/
    SharedPreferences sharedPreferences = context.getSharedPreferences("Zelory", Context.MODE_PRIVATE);
    switch (key) {
    case "lat":
        isi = sharedPreferences.getFloat(key, -7.7521492f);
        break;
    case "lon":
        isi = sharedPreferences.getFloat(key, 110.377659f);
        break;
    default:
        isi = sharedPreferences.getFloat(key, 0);
    }

    return isi;
}

From source file:alaindc.crowdroid.RadioUtils.java

public static String[] getTelInfo(Context context) {
    TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    String netType = getNetClass(context);
    String operatorName = mTelephonyManager.getNetworkOperatorName();

    SharedPreferences sharedPref = context.getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE);
    String signalStrength = sharedPref.getString(Constants.PREF_SENSOR_ + Constants.TYPE_TEL, "0");
    String throughput = String.valueOf(sharedPref.getFloat(Constants.THROUGHPUT_VALUE, 0));

    return new String[] { netType, signalStrength, operatorName, throughput };
}