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


Java SharedPreferences.Editor方法代码示例

本文整理汇总了Java中android.content.SharedPreferences.Editor方法的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferences.Editor方法的具体用法?Java SharedPreferences.Editor怎么用?Java SharedPreferences.Editor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.SharedPreferences的用法示例。


在下文中一共展示了SharedPreferences.Editor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPersonName

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static void setPersonName(String personIdToAdd, String personName, String personGroupId, Context context) {
    SharedPreferences personIdNameMap =
            context.getSharedPreferences(personGroupId + "PersonIdNameMap", Context.MODE_PRIVATE);

    SharedPreferences.Editor personIdNameMapEditor = personIdNameMap.edit();
    personIdNameMapEditor.putString(personIdToAdd, personName);
    personIdNameMapEditor.commit();

    Set<String> personIds = getAllPersonIds(personGroupId, context);
    Set<String> newPersonIds = new HashSet<>();
    for (String personId: personIds) {
        newPersonIds.add(personId);
    }
    newPersonIds.add(personIdToAdd);
    SharedPreferences personIdSet =
            context.getSharedPreferences(personGroupId + "PersonIdSet", Context.MODE_PRIVATE);
    SharedPreferences.Editor personIdSetEditor = personIdSet.edit();
    personIdSetEditor.putStringSet("PersonIdSet", newPersonIds);
    personIdSetEditor.commit();
}
 
开发者ID:interritus1996,项目名称:memento-app,代码行数:21,代码来源:StorageHelper.java

示例2: deleteSettings

import android.content.SharedPreferences; //导入方法依赖的package包/类
private int deleteSettings(int uid) {
	int rows = 0;
	String sUid = Integer.toString(uid);
	SharedPreferences prefs = getContext().getSharedPreferences(PREF_SETTINGS, Context.MODE_WORLD_READABLE);
	SharedPreferences.Editor editor = prefs.edit();
	for (String pref : prefs.getAll().keySet()) {
		String[] component = pref.split("\\.");
		if (component.length >= 3 && component[2].equals(sUid)) {
			Util.log(null, Log.INFO, "Removed setting=" + pref + " uid=" + uid);
			editor.remove(pref);
			rows++;
		}
	}
	editor.commit();
	setPrefFileReadable(PREF_SETTINGS);
	return rows;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:18,代码来源:PrivacyProvider.java

示例3: updateLockStatus

import android.content.SharedPreferences; //导入方法依赖的package包/类
private void updateLockStatus ( Boolean value )
{
	 SharedPreferences prefs = getSharedPreferences( Constant.PREF_NAME , 0 );
	 SharedPreferences.Editor editor = prefs.edit();
	 
	 editor.putBoolean( Constant.FACE_LOCK_STATUS_PREF , value );
	 editor.commit();
}
 
开发者ID:informramiz,项目名称:Android-Face-Recognition,代码行数:9,代码来源:EnableFaceLockActivity.java

示例4: saveSavedLogin

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static void saveSavedLogin(String info) {
    if (wifiName != null) {
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString(wifiName, info);
        editor.commit();
    }
}
 
开发者ID:jsparber,项目名称:CaptivePortalAutologin,代码行数:8,代码来源:CaptivePortalLoginActivity.java

示例5: onLoginButtonClick

import android.content.SharedPreferences; //导入方法依赖的package包/类
@OnClick(R.id.login_button)
public void onLoginButtonClick() {

    if(checkBox.isChecked()){
        SharedPreferences settings = getSharedPreferences(KEY_USERNAME, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("User", userLogin.getEditText().getText().toString());
        editor.apply();
    }

    attemptLogin();

}
 
开发者ID:hacktoberfest17,项目名称:programming,代码行数:14,代码来源:Login.java

示例6: remove

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * 移除某个key值已经对应的值
 * @param context
 * @param key
 */
public static void remove(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.remove(key);
    SharedPreferencesCompat.apply(editor);
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:13,代码来源:SPUtil.java

示例7: storeImmediate

import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
@SuppressLint("ApplySharedPref") // this is the intended behavior
public void storeImmediate(String key, Object toStore) {
    final SharedPreferences.Editor editor = mSp.edit();
    storeObject(editor, key, toStore);
    editor.commit();
}
 
开发者ID:jibbo,项目名称:SweetPrefs,代码行数:8,代码来源:SharedPreferenceStorage.java

示例8: onTokenRefresh

import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
public void onTokenRefresh() {
    super.onTokenRefresh();

    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d("Firebase", "Token is : "+refreshedToken);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString("firebaseToken", refreshedToken);
    editor.putString("firebaseTokenRefreshed", "false");
    editor.apply();

}
 
开发者ID:kunalrmhatre,项目名称:fussroll,代码行数:15,代码来源:GetFirebaseToken.java

示例9: deleteToken

import android.content.SharedPreferences; //导入方法依赖的package包/类
public void deleteToken()
{
    SharedPreferences sharedPreferences = mCtx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();

    editor.clear();
    editor.apply();
}
 
开发者ID:ThomasDelaney,项目名称:TapIn,代码行数:9,代码来源:messageTokenManager.java

示例10: clearOnlineStatus

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * @param context
 */
public static void clearOnlineStatus(Context context){
    SharedPreferences userInfos=context.getSharedPreferences(SPNAME, 0);
    SharedPreferences.Editor editor = userInfos.edit();
    editor.remove("online");
    editor.commit();
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:10,代码来源:UserSharedPreferences.java

示例11: clear

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * 清除所有数据
 */
public static void clear(Context context){

    SharedPreferences sp = context.getSharedPreferences(getSpName(context),Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear();
    org.androidannotations.api.sharedpreferences.SharedPreferencesCompat.apply(editor);
}
 
开发者ID:popo1379,项目名称:popomusic,代码行数:11,代码来源:SPUtil.java

示例12: setKokisShort

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static void setKokisShort(String key, short value){
    String convertedShortString = convertShortToString(value);
    final SharedPreferences.Editor editor = getSharedPreferencesObject().edit();
    editor.putString(key, convertedShortString);
    editor.commit();
}
 
开发者ID:PrihanNimsara,项目名称:KokisAndroidLibrary,代码行数:7,代码来源:Kokis.java

示例13: setDownloadType

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * Function to set witch type of download you do
 *
 * @param type integer refer to download type
 */
public static void setDownloadType(int type) {
    SharedPreferences.Editor editor = OpenConfigPreferences().edit();
    editor.putInt(AppConstants.Preferences.DOWNLOAD_TYPE, type);
    editor.apply();
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:11,代码来源:AppPreference.java

示例14: putInt

import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
 * 保存一个int类型的值!
 */
public static void putInt(String key, int value) {
    SharedPreferences.Editor editor = getSharedPreference(CONFIG).edit();
    editor.putInt(key, value).apply();
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:8,代码来源:SPUtils.java

示例15: clearPreference

import android.content.SharedPreferences; //导入方法依赖的package包/类
public static void clearPreference() {
    final SharedPreferences.Editor editor = getSharedPreferences().edit();
    editor.clear();
    editor.commit();
}
 
开发者ID:chengkun123,项目名称:ReadMark,代码行数:6,代码来源:SPUtils.java


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