当前位置: 首页>>代码示例>>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;未经允许,请勿转载。