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


Java Editor.putFloat方法代码示例

本文整理汇总了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);
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:21,代码来源:PreferenceUtil.java

示例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();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:e.java

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

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

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

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:PlatformDb.java

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

示例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();
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:9,代码来源:PreferenceUtil.java

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

示例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();
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:9,代码来源:PreferenceUtil.java

示例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();
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:46,代码来源:MIP_SharedPreferencesUtils.java

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

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

示例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");

}
 
开发者ID:monolifed,项目名称:mininoteview,代码行数:12,代码来源:Settings.java

示例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");

}
 
开发者ID:monolifed,项目名称:mininoteview,代码行数:13,代码来源:Settings.java


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