當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。