本文整理汇总了Java中android.content.SharedPreferences.Editor.putStringSet方法的典型用法代码示例。如果您正苦于以下问题:Java Editor.putStringSet方法的具体用法?Java Editor.putStringSet怎么用?Java Editor.putStringSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences.Editor
的用法示例。
在下文中一共展示了Editor.putStringSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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();
}
示例4: saveProfileList
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void saveProfileList(Context context) {
SharedPreferences sharedprefs = context.getSharedPreferences(PREFS_NAME, Activity.MODE_PRIVATE);
Editor editor = sharedprefs.edit();
editor.putStringSet("vpnlist", profiles.keySet());
// For reasing I do not understand at all
// Android saves my prefs file only one time
// if I remove the debug code below :(
int counter = sharedprefs.getInt("counter", 0);
editor.putInt("counter", counter + 1);
editor.apply();
}
示例5: setReceiverDeviceIds
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Set the list of receiver device ids.
*
* @param receiverDeviceIds the device ids.
*/
protected void setReceiverDeviceIds(Set<String> receiverDeviceIds) {
assert (receiverDeviceIds != null);
Editor prefEdit = preferences.edit();
prefEdit.putStringSet(context.getString(R.string.settings_selected_receivers_title), receiverDeviceIds);
prefEdit.apply();
}
示例6: updateExcludedApps
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void updateExcludedApps(Set<String> excludedApps) {
Editor editor = PreferenceManager.getDefaultSharedPreferences(this.context).edit();
editor.putStringSet(KEY_EXCLUDED_APPS, excludedApps);
editor.commit();
}