本文整理汇总了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();
}
}
}
示例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();
}
示例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();
}
示例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");
}
示例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();
}
示例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();
}
}
示例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;
}
示例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();
}
示例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();
}
示例10: storeOpenUDID
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void storeOpenUDID() {
final Editor e = mPreferences.edit();
e.putString(PREF_KEY, OpenUDID);
e.commit();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}