当前位置: 首页>>代码示例>>Java>>正文


Java SharedPreferences.getFloat方法代码示例

本文整理汇总了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");
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:26,代码来源:Pedometer.java

示例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;
}
 
开发者ID:xiaobaima520gyj,项目名称:imooc-imi-app,代码行数:33,代码来源:SPUtils.java

示例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;
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:21,代码来源:SPUtils.java

示例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;
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:27,代码来源:SPUtil.java

示例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;
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:26,代码来源:SPUtil.java

示例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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:26,代码来源:SPUtils.java

示例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();
}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:16,代码来源:STLView.java

示例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);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:15,代码来源:SPHelper.java

示例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;
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:16,代码来源:SPUtils.java

示例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));
    }
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:13,代码来源:ActNewFlight.java

示例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);
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:8,代码来源:SPUtils.java

示例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);
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:7,代码来源:Utility.java

示例13: get

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static float get(SharedPreferences prefs, @NonNull String key, float defaultValue) {
    return prefs.getFloat(key, defaultValue);
}
 
开发者ID:hisaichi5518,项目名称:konohana,代码行数:4,代码来源:FloatPrefsAdapter.java

示例14: getParam

import android.content.SharedPreferences; //导入方法依赖的package包/类
public float getParam(String key, float defValue) {
    SharedPreferences spf = getSharedPreferences(context);
    return spf.getFloat(key, defValue);
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:5,代码来源:Preference.java

示例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);
}
 
开发者ID:harrylefit,项目名称:eazycore,代码行数:14,代码来源:PreferencesUtils.java


注:本文中的android.content.SharedPreferences.getFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。