List of usage examples for android.content SharedPreferences getFloat
float getFloat(String key, float defValue);
From source file:com.example.cal.mysunshine.Utility.java
public static float getLocationLatitude(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getFloat(context.getString(R.string.pref_location_latitude), DEFAULT_LATLONG); }
From source file:com.example.cal.mysunshine.Utility.java
public static float getLocationLongitude(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getFloat(context.getString(R.string.pref_location_longitude), DEFAULT_LATLONG); }
From source file:Main.java
public static Object getData(Context context, String fileName, String key, Class clazz) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); if (clazz.getName().equals(String.class.getName())) { return sharedPreferences.getString(key, ""); } else if (clazz.getName().equals(Integer.class.getName())) { return sharedPreferences.getInt(key, 0); } else if (clazz.getName().equals(Float.class.getName())) { return sharedPreferences.getFloat(key, 0); } else if (clazz.getName().equals(Long.class.getName())) { return sharedPreferences.getLong(key, 0); } else {//from ww w . j a v a 2s . c o m return sharedPreferences.getBoolean(key, false); } }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static float getRate(Activity context) { SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0); return settingsToGet.getFloat(BRConstants.RATE, 1); }
From source file:Main.java
public static <T> T getData(Context context, String fileName, String key, Class T) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); T result;/*from ww w .j a v a2 s .c om*/ if (String.class.isAssignableFrom(T)) { result = (T) sharedPreferences.getString(key, ""); } else if (Integer.class.isAssignableFrom(T)) { result = (T) Integer.valueOf(sharedPreferences.getInt(key, 0)); } else if (Float.class.isAssignableFrom(T)) { result = (T) Float.valueOf(sharedPreferences.getFloat(key, 0)); } else if (Long.class.isAssignableFrom(T)) { result = (T) Long.valueOf(sharedPreferences.getLong(key, 0)); } else { result = (T) Boolean.valueOf(sharedPreferences.getBoolean(key, false)); } return result; }
From source file:Main.java
public static Object getParam(Context context, String key, Object defaultObject) { String type = defaultObject.getClass().getSimpleName(); SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); if ("String".equals(type)) { return sp.getString(key, (String) defaultObject); } else if ("Integer".equals(type)) { return sp.getInt(key, (Integer) defaultObject); } else if ("Boolean".equals(type)) { return sp.getBoolean(key, (Boolean) defaultObject); } else if ("Float".equals(type)) { return sp.getFloat(key, (Float) defaultObject); } else if ("Long".equals(type)) { return sp.getLong(key, (Long) defaultObject); }//from ww w . ja va 2s.c o m return null; }
From source file:Main.java
public static Object getSp(Context context, String key, Object defaultObject) { String type = defaultObject.getClass().getSimpleName(); String packageName = context.getPackageName(); SharedPreferences sp = context.getSharedPreferences(packageName, Context.MODE_PRIVATE); if ("String".equals(type)) { return sp.getString(key, (String) defaultObject); } else if ("Integer".equals(type)) { return sp.getInt(key, (Integer) defaultObject); } else if ("Boolean".equals(type)) { return sp.getBoolean(key, (Boolean) defaultObject); } else if ("Float".equals(type)) { return sp.getFloat(key, (Float) defaultObject); } else if ("Long".equals(type)) { return sp.getLong(key, (Long) defaultObject); }/* ww w . j a v a 2s . co m*/ return null; }
From source file:Main.java
public static Object get(Context context, String key, Object defaultObject) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); if (defaultObject instanceof String) { return sp.getString(key, (String) defaultObject); } else if (defaultObject instanceof Integer) { return sp.getInt(key, (Integer) defaultObject); } else if (defaultObject instanceof Boolean) { return sp.getBoolean(key, (Boolean) defaultObject); } else if (defaultObject instanceof Float) { return sp.getFloat(key, (Float) defaultObject); } else if (defaultObject instanceof Long) { return sp.getLong(key, (Long) defaultObject); }/* ww w . j a v a2 s .c o m*/ return null; }
From source file:Main.java
public static Object get(Context context, String key, Object defaultObject) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); if (defaultObject instanceof String) { return sp.getString(key, (String) defaultObject); } else if (defaultObject instanceof Integer) { return sp.getInt(key, (Integer) defaultObject); } else if (defaultObject instanceof Boolean) { return sp.getBoolean(key, (Boolean) defaultObject); } else if (defaultObject instanceof Float) { return sp.getFloat(key, (Float) defaultObject); } else if (defaultObject instanceof Long) { return sp.getLong(key, (Long) defaultObject); }//from w w w . j av a 2 s . com return null; }
From source file:fr.eoit.parameter.Parameters.java
public static void loadParameters(FragmentActivity pActivity) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(pActivity); characterId = preferences.getLong("character_id", -1); keyId = preferences.getLong("user_id", -1); vCode = preferences.getString("api_key", null); isMiningActive = preferences.getBoolean("mining_active", true); territory = preferences.getInt("territory", EOITConst.Territories.CALDARI_SPACE); securityStatus = preferences.getFloat("security_status", 0.7f); context = pActivity.getApplicationContext(); if (keyId == -1 && vCode == null) { Skills.setLevelVChar(true);/*from ww w.j ava2 s . co m*/ } pActivity.getSupportLoaderManager().initLoader(PARAM_LOADER_ID, null, new Parameters()); pActivity.getSupportLoaderManager().initLoader(STATIONS_LOADER_ID, null, new Parameters()); validateStationParams(pActivity); }