當前位置: 首頁>>代碼示例>>Java>>正文


Java Editor.putString方法代碼示例

本文整理匯總了Java中android.content.SharedPreferences.Editor.putString方法的典型用法代碼示例。如果您正苦於以下問題:Java Editor.putString方法的具體用法?Java Editor.putString怎麽用?Java Editor.putString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.SharedPreferences.Editor的用法示例。


在下文中一共展示了Editor.putString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeDataToSharePreference

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void writeDataToSharePreference(Context context, String str, String str2, String str3) {
    if (str3 != null) {
        Editor edit = context.getSharedPreferences(str, 0).edit();
        if (edit != null) {
            edit.clear();
            edit.putString(str2, str3);
            edit.commit();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:SharePreferenceStorage.java

示例2: putString

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private static void putString(String key, String value)
{

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(HeroVideoApp.getInstance());
    Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    editor.apply();
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:9,代碼來源:PreferenceUtil.java

示例3: setLogLinePeriodPreference

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void setLogLinePeriodPreference(Context context, int value) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    Editor editor = sharedPrefs.edit();

    editor.putString(context.getText(R.string.pref_log_line_period).toString(), Integer.toString(value));

    editor.commit();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:9,代碼來源:PreferenceHelper.java

示例4: setEnvironment

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setEnvironment(Context context, int i) {
    if (context != null && (this.c == null || this.c.get() == null)) {
        this.c = new WeakReference(context.getSharedPreferences("ServerPrefs", 0));
    }
    if (i == 0 || i == 1) {
        Editor edit;
        switch (i) {
            case 0:
                edit = ((SharedPreferences) this.c.get()).edit();
                edit.putInt("ServerType", 0);
                edit.putString(KEY_OPEN_ENV, "formal");
                edit.putString(KEY_HOST_QZS_QQ, KEY_HOST_QZS_QQ);
                edit.putString(KEY_HOST_OPEN_MOBILE, KEY_HOST_OPEN_MOBILE);
                edit.commit();
                changeServer();
                Toast.makeText(context, "已切換到正式環境", 0).show();
                return;
            case 1:
                edit = ((SharedPreferences) this.c.get()).edit();
                edit.putInt("ServerType", 1);
                edit.putString(KEY_OPEN_ENV, "exp");
                edit.putString(KEY_HOST_QZS_QQ, "testmobile.qq.com");
                edit.putString(KEY_HOST_OPEN_MOBILE, "test.openmobile.qq.com");
                edit.commit();
                changeServer();
                Toast.makeText(context, "已切換到體驗環境", 0).show();
                return;
            default:
                return;
        }
    }
    f.e(a, "切換環境參數錯誤,正式環境為0,體驗環境為1");
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:34,代碼來源:ServerSetting.java

示例5: 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

示例6: setGiftJson

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setGiftJson(String json) {
    if (json == null) {
        json = "";
    }
    if (!json.equals(getGiftJson())) {
        Editor e = getSharedPreferences().edit();
        e.putString("sp_gift_json", json);
        e.commit();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:11,代碼來源:RedPacketSharePreferences.java

示例7: getAndroidUUID

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
@Kroll.method
public synchronized String getAndroidUUID() {
    if (uniqueID == null) {
        SharedPreferences sharedPrefs = TiApplication.getInstance().getApplicationContext().getSharedPreferences(
                PREF_UNIQUE_ID, Context.MODE_PRIVATE);
        uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
        if (uniqueID == null) {
            uniqueID = UUID.randomUUID().toString();
            Editor editor = sharedPrefs.edit();
            editor.putString(PREF_UNIQUE_ID, uniqueID);
            editor.commit();
        }
    }
    return uniqueID;
}
 
開發者ID:grazianogrespan,項目名稱:Ti.AndroidID,代碼行數:16,代碼來源:AndroidDeviceIdModule.java

示例8: setDefaults

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * Set default initial settings
 *
 * @param context context
 */
@SuppressLint({"CommitPrefEdits", "ApplySharedPref"})
static public void setDefaults(final Context context)
{
	final String externalStorage = Storage.getExternalStorage();
	//final File treebolicStorage = Storage.getTreebolicStorage(context);
	//final Uri uri = Uri.fromFile(treebolicStorage);

	final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
	final Editor editor = sharedPref.edit();
	editor.putString(TreebolicIface.PREF_SOURCE, externalStorage);
	editor.commit();
}
 
開發者ID:1313ou,項目名稱:TreebolicPlugins,代碼行數:18,代碼來源:Settings.java

示例9: saveFingerprint

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private void saveFingerprint(String fileName, String md5) {
    Editor editor = this.mContext.getSharedPreferences(SP_NAME, 0).edit();
    editor.putString(fileName + SP_MD5, md5);
    editor.commit();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:6,代碼來源:SecurityChecker.java

示例10: storeOpenUDID

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private void storeOpenUDID() {
   	final Editor e = mPreferences.edit();
	e.putString(PREF_KEY, OpenUDID);
	e.commit();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:OpenUDID_manager.java

示例11: setDeviceId

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setDeviceId(Context context, String deviceId) {
    Editor editor = context.getSharedPreferences(SETTINGS, 4).edit();
    editor.putString("letv_deviceId", deviceId);
    editor.commit();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:6,代碼來源:PreferencesManager.java

示例12: saveRefreshToken

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void saveRefreshToken(Context context, SHARE_MEDIA share_media, String str) {
    Editor edit = context.getSharedPreferences(SocializeConstants
            .SOCIAL_PREFERENCE_REFRESH_TOKEN, 0).edit();
    edit.putString(share_media.toString(), str);
    edit.commit();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:OauthHelper.java

示例13: setProviderDevice

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * @param provider
 */
public void setProviderDevice(Device provider) {
    Editor prefEdit = preferences.edit();
    prefEdit.putString(context.getString(R.string.settings_selected_provider_title), provider.getIdentity().getUdn().getIdentifierString());
    prefEdit.apply();
}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:9,代碼來源:UpnpClient.java

示例14: setStringValue

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setStringValue(SharedPreferences preferences, String key, String value) {
    Editor editor = preferences.edit();
    editor.putString(key, value);
    editor.commit();
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:6,代碼來源:PreferencesUtil.java

示例15: commitStringForTyping

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private void commitStringForTyping(StringForTyping theItem) {
	
	if ((mKp2aRememberAutoFill) && (!TextUtils.isEmpty(getCurrentInputEditorInfo().hintText)))
	{
		EditorInfo editorInfo = getCurrentInputEditorInfo();
		String key = editorInfo.packageName+"/"+keepass2android.kbbridge.KeyboardData.entryId+"/"+editorInfo.hintText;
		SharedPreferences prefs = getApplicationContext().getSharedPreferences(KP2A_SAVED_FIELD_HINTS, MODE_PRIVATE);
		
		Editor edit = prefs.edit();
		
		edit.putString(key, theItem.key);
		edit.commit();	
	}
	
	
									
	Log.d("KP2AK", "committing text for " + theItem.key);
	commitKp2aString(theItem.value, getCurrentInputEditorInfo());
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:20,代碼來源:KP2AKeyboard.java


注:本文中的android.content.SharedPreferences.Editor.putString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。