本文整理汇总了Java中android.content.SharedPreferences.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferences.getFloat方法的具体用法?Java SharedPreferences.getFloat怎么用?Java SharedPreferences.getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences
的用法示例。
在下文中一共展示了SharedPreferences.getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Pedometer
import android.content.SharedPreferences; //导入方法依赖的package包/类
/** Constructor. */
public Pedometer(ComponentContainer container) {
super(container.$form());
context = container.$context();
// some initialization
winPos = 0;
startPeaking = false;
numStepsWithFilter = 0;
numStepsRaw = 0;
foundValley = true;
lastValley = 0;
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
// Restore preferences
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
strideLength = settings.getFloat("Pedometer.stridelength", STRIDE_LENGTH);
totalDistance = settings.getFloat("Pedometer.distance", 0);
numStepsRaw = settings.getInt("Pedometer.prevStepCount", 0);
prevStopClockTime = settings.getLong("Pedometer.clockTime", 0);
numStepsWithFilter = numStepsRaw;
startTime = System.currentTimeMillis();
Log.d(TAG, "Pedometer Created");
}
示例2: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
*
* @param context
* @param key
* @param defaultObject
* @return
*/
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);
}
return null;
}
示例3: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static Object get(String fileName, Context context, String key, Object defaultObject) {
SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
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);
} else if (null == defaultObject) {
return sp.getString(key, null);
}
return null;
}
示例4: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
*
* @param context
* @param key
* @param defaultObject
* @return
*/
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);
}
return null;
}
示例5: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 获取存放object
* @param context
* @param fileName
* @param key
* @param def
* @return
*/
public static Object get(Context context, String fileName, String key, Object def) {
SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
if (def instanceof String) {
return sp.getString(key, def.toString());
} else if (def instanceof Integer) {
return sp.getInt(key, ((Integer) def).intValue());
} else if (def instanceof Boolean) {
return sp.getBoolean(key, ((Boolean) def).booleanValue());
} else if (def instanceof Float) {
return sp.getFloat(key, ((Float) def).floatValue());
} else if (def instanceof Long) {
return sp.getLong(key, ((Long) def).longValue());
} else if (def instanceof Set) {
return sp.getStringSet(key, (Set<String>) def);
}
return def;
}
示例6: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
*
* @param key
* @param defaultObject
* @return
*/
public static Object get(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);
}
return null;
}
示例7: STLView
import android.content.SharedPreferences; //导入方法依赖的package包/类
public STLView(Context context, STLObject stlObject) {
super(context);
SharedPreferences colorConfig = context.getSharedPreferences("colors", Activity.MODE_PRIVATE);
STLRenderer.red = colorConfig.getFloat("red", 0.75f);
STLRenderer.green = colorConfig.getFloat("green", 0.75f);
STLRenderer.blue = colorConfig.getFloat("blue", 0.75f);
STLRenderer.alpha = colorConfig.getFloat("alpha", 0.5f);
// render: stlObject as null
stlRenderer = new STLRenderer(stlObject);
setRenderer(stlRenderer);
stlRenderer.requestRedraw();
}
示例8: getFloat
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static float getFloat(String name, float defaultValue) {
SharedPreferences sp = getSP(name);
if (sp == null) {
ContentResolver cr = mContext.getContentResolver();
Uri uri = Uri.parse(CONTENT_URI + SEPARATOR + TYPE_FLOAT + SEPARATOR + name);
String rtn = cr.getType(uri);
if (rtn == null || rtn.equals(NULL_STRING)) {
return defaultValue;
}
return Float.parseFloat(rtn);
} else {
return sp.getFloat(name, defaultValue);
}
}
示例9: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static Object get(String key, Object defaultObject) {
SharedPreferences sp = CommonApp.getInstance().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);
}
return null;
}
示例10: RestoreState
import android.content.SharedPreferences; //导入方法依赖的package包/类
private void RestoreState() {
try {
SharedPreferences mPrefs = getActivity().getPreferences(Activity.MODE_PRIVATE);
ActNewFlight.fPaused = mPrefs.getBoolean(m_KeysIsPaused, false);
ActNewFlight.dtPauseTime = mPrefs.getLong(m_KeysPausedTime, 0);
ActNewFlight.dtTimeOfLastPause = mPrefs.getLong(m_KeysTimeOfLastPause, 0);
ActNewFlight.accumulatedNight = (double) mPrefs.getFloat(m_KeysAccumulatedNight, (float) 0.0);
} catch (Exception e) {
Log.e(MFBConstants.LOG_TAG, Log.getStackTraceString(e));
}
}
示例11: getFloat
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 获取float的value
*/
public static float getFloat(String key, Float defValue) {
SharedPreferences sharedPreference = getSharedPreference(CONFIG);
return sharedPreference.getFloat(key, defValue);
}
示例12: getLocationLatitude
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static float getLocationLatitude(Context context) {
SharedPreferences prefs
= PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getFloat(context.getString(R.string.pref_location_latitude),
DEFAULT_LATLONG);
}
示例13: get
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static float get(SharedPreferences prefs, @NonNull String key, float defaultValue) {
return prefs.getFloat(key, defaultValue);
}
示例14: getParam
import android.content.SharedPreferences; //导入方法依赖的package包/类
public float getParam(String key, float defValue) {
SharedPreferences spf = getSharedPreferences(context);
return spf.getFloat(key, defValue);
}
示例15: getFloat
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* get float preferences
*
* @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);
}