本文整理匯總了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");
}