本文整理汇总了Java中android.content.SharedPreferences.Editor.putFloat方法的典型用法代码示例。如果您正苦于以下问题:Java Editor.putFloat方法的具体用法?Java Editor.putFloat怎么用?Java Editor.putFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences.Editor
的用法示例。
在下文中一共展示了Editor.putFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void put(Context context, String spName, String key, Object object) {
SharedPreferences sp = context.getSharedPreferences(spName,
Context.MODE_PRIVATE);
Editor editor = sp.edit();
if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, (Integer) object);
} else if (object instanceof Boolean) {
editor.putBoolean(key, (Boolean) object);
} else if (object instanceof Float) {
editor.putFloat(key, (Float) object);
} else if (object instanceof Long) {
editor.putLong(key, (Long) object);
} else {
editor.putString(key, object.toString());
}
editSubmit(editor);
}
示例2: a
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void a(String str, Object obj) {
Editor edit = c.edit();
if (obj.getClass() == Boolean.class) {
edit.putBoolean(str, ((Boolean) obj).booleanValue());
}
if (obj.getClass() == String.class) {
edit.putString(str, (String) obj);
}
if (obj.getClass() == Integer.class) {
edit.putInt(str, ((Integer) obj).intValue());
}
if (obj.getClass() == Float.class) {
edit.putFloat(str, (float) ((Float) obj).intValue());
}
if (obj.getClass() == Long.class) {
edit.putLong(str, (long) ((Long) obj).intValue());
}
edit.commit();
}
示例3: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void put(Context context, boolean isSyn, String fileName, String key, Object
object) {
if (object != null) {
Editor editor = context.getSharedPreferences(fileName, 4).edit();
if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, ((Integer) object).intValue());
} else if (object instanceof Boolean) {
editor.putBoolean(key, ((Boolean) object).booleanValue());
} else if (object instanceof Float) {
editor.putFloat(key, ((Float) object).floatValue());
} else if (object instanceof Long) {
editor.putLong(key, ((Long) object).longValue());
} else {
editor.putString(key, object.toString());
}
if (isSyn) {
editor.commit();
} else {
SharedPreferencesCompat.apply(editor);
}
}
}
示例4: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 存入某个key对应的value值
*
* @param context
* @param key
* @param value
*/
public static void put(Context context, String key, Object value) {
SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE);
Editor edit = sp.edit();
if (value instanceof String) {
edit.putString(key, (String) value);
} else if (value instanceof Integer) {
edit.putInt(key, (Integer) value);
} else if (value instanceof Boolean) {
edit.putBoolean(key, (Boolean) value);
} else if (value instanceof Float) {
edit.putFloat(key, (Float) value);
} else if (value instanceof Long) {
edit.putLong(key, (Long) value);
} else if (value instanceof Set) {
edit.putStringSet(key, (Set<String>) value);
}
SharedPreferencesCompat.EditorCompat.getInstance().apply(edit);
}
示例5: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 存放object
*
* @param context
* @param fileName
* @param key
* @param object
* @return
*/
public static boolean put(Context context, String fileName, String key, Object object) {
SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
Editor editor = sp.edit();
if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, ((Integer) object).intValue());
} else if (object instanceof Boolean) {
editor.putBoolean(key, ((Boolean) object).booleanValue());
} else if (object instanceof Float) {
editor.putFloat(key, ((Float) object).floatValue());
} else if (object instanceof Long) {
editor.putLong(key, ((Long) object).longValue());
} else if (object instanceof Set) {
editor.putStringSet(key, (Set<String>) object);
} else {
editor.putStringSet(key, (Set<String>) object);
}
return editor.commit();
}
示例6: importData
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void importData(String str) {
try {
HashMap fromJson = new Hashon().fromJson(str);
if (fromJson != null) {
Editor edit = this.db.edit();
for (Entry entry : fromJson.entrySet()) {
Object value = entry.getValue();
if (value instanceof Boolean) {
edit.putBoolean((String) entry.getKey(), ((Boolean) value).booleanValue());
} else if (value instanceof Float) {
edit.putFloat((String) entry.getKey(), ((Float) value).floatValue());
} else if (value instanceof Integer) {
edit.putInt((String) entry.getKey(), ((Integer) value).intValue());
} else if (value instanceof Long) {
edit.putLong((String) entry.getKey(), ((Long) value).longValue());
} else {
edit.putString((String) entry.getKey(), String.valueOf(value));
}
}
edit.commit();
}
} catch (Throwable th) {
Ln.w(th);
}
}
示例7: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void put(String fileName, Context context, String key, Object object) {
SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
Context.MODE_PRIVATE);
Editor editor = sp.edit();
if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, (Integer) object);
} else if (object instanceof Boolean) {
editor.putBoolean(key, (Boolean) object);
} else if (object instanceof Float) {
editor.putFloat(key, (Float) object);
} else if (object instanceof Long) {
editor.putLong(key, (Long) object);
} else if (object instanceof Set) {
editor.putStringSet(key, (Set) object);
} else if(object == null) {
editor.remove(key);
}
editor.apply();
}
示例8: putFloat
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void putFloat(String key, float value)
{
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(HeroVideoApp.getInstance());
Editor editor = sharedPreferences.edit();
editor.putFloat(key, value);
editor.apply();
}
示例9: setPreferenceFloatValue
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Set a preference float value
* @param key the preference key to set
* @param value the value for this key
*/
public void setPreferenceFloatValue(String key, float value) {
if(sharedEditor == null) {
Editor editor = prefs.edit();
editor.putFloat(key, value);
editor.commit();
}else {
sharedEditor.putFloat(key, value);
}
}
示例10: putFloat
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void putFloat(String key, float value) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
BilibiliApp.getInstance());
Editor editor = sharedPreferences.edit();
editor.putFloat(key, value);
editor.apply();
}
示例11: setValueToSharePre
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 设置变量到sharePrefernce中
*
* @param key
* @param value
*/
public static void setValueToSharePre(Context mContext, String share_name, String key, Object value)
{
SharedPreferences sharedoPreferences = mContext.getSharedPreferences(share_name, Context.MODE_PRIVATE);
Editor editor = sharedoPreferences.edit();
if (value instanceof String)
{
editor.putString(key, (String)value);
}
else if (value instanceof Integer)
{
editor.putInt(key, (Integer)value);
}
else if (value instanceof Long)
{
editor.putLong(key, (Long)value);
}
else if (value instanceof Float)
{
editor.putFloat(key, (Float)value);
}
else if (value instanceof Boolean)
{
editor.putBoolean(key, (Boolean)value);
}
else
{
LogUtil.i("setValueToSharePre no matching type");
}
editor.commit();
}
示例12: setValue
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/***
* 设置配置值
*
* param key 配置变量名
* param value 配置数值
*/
public void setValue(String key, float value) {
SharedPreferences preferences = context.getSharedPreferences(KEEPERNAME, Context.MODE_PRIVATE);
Editor editor = preferences.edit();
editor.putFloat(key, value);
editor.apply();
}
示例13: setPreferences
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void setPreferences(Context context, String preference, String key, float value){
if(context==null) return;
SharedPreferences sharedPreferences = context.getSharedPreferences(preference, Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.putFloat(key, value);
editor.commit();
}
示例14: setFontSize
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void setFontSize(float size)
{
fontSize = size;
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor ed = sp.edit();
ed.putFloat(getString(R.string.prefFontSizeKey), fontSize);
ed.apply();
mFontSizePref.setSummary(getText(R.string.prefFontSizeSummary) + ": " + Float.toString(fontSize) + " sp");
}
示例15: setFontSizeOnList
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void setFontSizeOnList(float size)
{
fontSizeOnList = size;
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor ed = sp.edit();
ed.putFloat(getString(R.string.prefFontSizeOnListKey), fontSizeOnList);
ed.apply();
mFontSizeOnListPref.setSummary(getText(R.string.prefFontSizeOnListSummary) + ": " + Float.toString(fontSizeOnList) + " sp");
}