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


Java Editor.putStringSet方法代码示例

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

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

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

示例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();
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:12,代码来源:ProfileManager.java

示例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();
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:12,代码来源:UpnpClient.java

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


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