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