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


Java Editor类代码示例

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


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

示例1: reset

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public void reset() {
	Editor editor = mSharedPref.edit();
	
	editor.putString(ACCESS_TOKEN, 	"");
	editor.putString(USERID, 		"");
	editor.putString(USERNAME, 		"");
	editor.putString(FULLNAME, 		"");
	editor.putString(PROFILPIC, 	"");
	editor.putInt(FOLLOW,0);
	editor.putInt(FOLLOWED,0);
	
	editor.commit();
	
	CookieSyncManager.createInstance(mContext);
	
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.removeAllCookie();
}
 
开发者ID:inceleb,项目名称:InstagramManager-Android,代码行数:19,代码来源:InstagramSession.java

示例2: updateList

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
protected void updateList() {
	if (prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false) != sortedByColor) {
		Editor edit = prefs.edit();
		edit.putBoolean(PreferenceConstants.SORT_BY_COLOR, sortedByColor);
		edit.apply();
	}

	if (hostdb == null)
		hostdb = HostDatabase.get(this);

	hosts = hostdb.getHosts(sortedByColor);

	// Don't lose hosts that are connected via shortcuts but not in the database.
	if (bound != null) {
		for (TerminalBridge bridge : bound.getBridges()) {
			if (!hosts.contains(bridge.host))
				hosts.add(0, bridge.host);
		}
	}

	mAdapter = new HostAdapter(this, hosts, bound);
	mListView.setAdapter(mAdapter);
	adjustViewVisibility();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:HostListActivity.java

示例3: removeAccessToken

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public static void removeAccessToken(Context ctx, String hostPackage,
		String accessToken) {
	SharedPreferences prefs = getPrefsForHost(ctx, hostPackage);

	Log.d(_tag, "removing AccessToken.");
	if (prefs.getString(PREF_KEY_TOKEN, "").equals(accessToken))
	{
		Editor edit = prefs.edit();
		edit.clear();
		edit.commit();

	}
	
	SharedPreferences hostPrefs = ctx.getSharedPreferences("KP2A.PluginAccess.hosts", Context.MODE_PRIVATE);
	if (hostPrefs.contains(hostPackage))
	{
		hostPrefs.edit().remove(hostPackage).commit();
	}
 
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:AccessManager.java

示例4: getUpdaterPopup

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public UpdaterPopupLauncher getUpdaterPopup(boolean fallbackAlert) {
	UpdaterPopupLauncher popLauncher = null;
	Editor edt = prefs.edit();
	int onlineVersion = getLastOnlineVersion();
	// Reset ignore check value
	edt.putBoolean(IGNORE_NIGHTLY_CHECK, false);
	if(pinfo != null && pinfo.versionCode < onlineVersion) {
		popLauncher = new UpdaterPopupLauncher(context, onlineVersion);
	}else {
		// Set last check to now :)
		edt.putLong(LAST_NIGHTLY_CHECK, System.currentTimeMillis());
		// And delete latest nightly from cache
		File cachedFile = getCachedFile();
		if(cachedFile.exists()) {
			cachedFile.delete();
		}
		if(fallbackAlert) {
			popLauncher = new UpdaterPopupLauncher(context, 0);
		}
	}
	edt.commit();
	
	return popLauncher;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:25,代码来源:NightlyUpdater.java

示例5: getAccountIdForCallHandler

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
/**
 * Retrieve internal id of call handler as saved in databases It should be
 * some negative < SipProfile.INVALID_ID number
 * 
 * @param ctxt Application context
 * @param packageName name of the call handler package
 * @return the id of this call handler in databases
 */
public static Long getAccountIdForCallHandler(Context ctxt, String packageName) {
    SharedPreferences prefs = ctxt.getSharedPreferences("handlerCache", Context.MODE_PRIVATE);

    long accountId = SipProfile.INVALID_ID;
    try {
        accountId = prefs.getLong(VIRTUAL_ACC_PREFIX + packageName, SipProfile.INVALID_ID);
    } catch (Exception e) {
        Log.e(THIS_FILE, "Can't retrieve call handler cache id - reset");
    }
    if (accountId == SipProfile.INVALID_ID) {
        // We never seen this one, add a new entry for account id
        int maxAcc = prefs.getInt(VIRTUAL_ACC_MAX_ENTRIES, 0x0);
        int currentEntry = maxAcc + 1;
        accountId = SipProfile.INVALID_ID - (long) currentEntry;
        Editor edt = prefs.edit();
        edt.putLong(VIRTUAL_ACC_PREFIX + packageName, accountId);
        edt.putInt(VIRTUAL_ACC_MAX_ENTRIES, currentEntry);
        edt.commit();
    }
    return accountId;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:30,代码来源:CallHandlerPlugin.java

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

示例7: getUrlAddParamer

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
private static String getUrlAddParamer(String url, Context context) {
    SharedPreferences setting = context.getSharedPreferences(TAG, 0);
    if (!setting.getBoolean("isInit", false)) {
        try {
            Editor edit = setting.edit();
            edit.putString(VERSION_NAME, context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName);
            edit.putString(MODEL, Build.MODEL);
            edit.putString("version", VERSION.RELEASE);
            edit.putString("url", url);
            edit.putBoolean("isInit", true);
            edit.commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    StringBuilder builder = new StringBuilder(url);
    builder.append("&model=" + setting.getString(MODEL, ""));
    builder.append("&os=android" + setting.getString("version", ""));
    builder.append("&version=" + setting.getString(VERSION_NAME, ""));
    return builder.toString();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:UninstalledObserver.java

示例8: logoutFromTwitter

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public void logoutFromTwitter() {
    stopListeningOnAKeyword();
    Editor e = mSharedPreferences.edit();
    e.remove(PREF_KEY_OAUTH_TOKEN);
    e.remove(PREF_KEY_OAUTH_SECRET);
    e.remove(PREF_KEY_TWITTER_LOGIN);
    e.remove(PREF_KEY_TWITTER_USERNAME);
    e.commit();
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:10,代码来源:TwitterShield.java

示例9: setBind

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public static void setBind(Context context, boolean flag) {
    String flagStr = "not";
    if (flag) {
        flagStr = "ok";
    }
    Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.putString("bind_flag", flagStr);
    editor.commit();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:Utils.java

示例10: setDefaults

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
/**
 * Set providers default settings from provider data
 *
 * @param context locatorContext
 */
@SuppressLint({"CommitPrefEdits", "ApplySharedPref"})
@SuppressWarnings("boxing")
static public void setDefaults(@NonNull final Context context)
{
	// create providers
	final List<HashMap<String, Object>> providers = Providers.getProviders(context, false);

	// create prefs for built-in providers
	if (providers != null)
	{
		for (int i = 0; i < providers.size(); i++)
		{
			final HashMap<String, Object> provider = providers.get(i);
			if (provider.get(Providers.ISPLUGIN).equals(true))
			{
				continue;
			}

			// provider shared preferences
			final SharedPreferences providerSharedPrefs = context.getSharedPreferences(Settings.PREF_FILE_PREFIX + provider.get(Providers.NAME), Context.MODE_PRIVATE);

			// commit non existent values
			final Editor providerEditor = providerSharedPrefs.edit();
			final String[] keys = new String[]{TreebolicIface.PREF_SOURCE, TreebolicIface.PREF_BASE, TreebolicIface.PREF_IMAGEBASE, TreebolicIface.PREF_SETTINGS, Settings.PREF_PROVIDER};
			final String[] providerKeys = new String[]{Providers.SOURCE, Providers.BASE, Providers.IMAGEBASE, Providers.SETTINGS, Providers.PROVIDER};
			for (int j = 0; j < keys.length; j++)
			{
				final String key = keys[j];
				if (!providerSharedPrefs.contains(key))
				{
					final String value = (String) provider.get(providerKeys[j]);
					providerEditor.putString(key, value).commit();
				}
			}
		}
	}
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:43,代码来源:Settings.java

示例11: setDatabasesUpToDate

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
/**
 * Remember that all account databases are using the most recent database schema.
 *
 * @param save
 *         Whether or not to write the current database version to the
 *         {@code SharedPreferences} {@link #DATABASE_VERSION_CACHE}.
 *
 * @see #areDatabasesUpToDate()
 */
public static synchronized void setDatabasesUpToDate(boolean save) {
    sDatabasesUpToDate = true;

    if (save) {
        Editor editor = sDatabaseVersionCache.edit();
        editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION);
        editor.apply();
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:QMail.java

示例12: removeAccount

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public void removeAccount() {
    ArrayList arrayList = new ArrayList();
    for (Entry key : this.db.getAll().entrySet()) {
        arrayList.add(key.getKey());
    }
    Editor edit = this.db.edit();
    Iterator it = arrayList.iterator();
    while (it.hasNext()) {
        edit.remove((String) it.next());
    }
    edit.commit();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:PlatformDb.java

示例13: savePreferences

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public void savePreferences() {
    SharedPreferences pref = MyApplication.getAppContext()
            .getSharedPreferences(preferenceKey, Context.MODE_PRIVATE);
    Editor editor = pref.edit();
    editor.putInt("showShanghan", showShanghan);
    editor.putInt("showJinkui", showJinkui);
    editor.commit();
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:9,代码来源:SingletonData.java

示例14: deleteValue

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
/**
 * Delete value method
 * @param context
 * @param key
 * @throws NoSuchAlgorithmException
 */
private static void deleteValue(@NonNull Context context, @NonNull String key) throws NoSuchAlgorithmException {
    SharedPreferences settings;
    Editor editor;

    settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    editor = settings.edit();

    editor.remove(key);
    editor.apply();
}
 
开发者ID:YoeriNijs,项目名称:NoteBuddy,代码行数:17,代码来源:KeyValueDB.java

示例15: remove

import android.content.SharedPreferences.Editor; //导入依赖的package包/类
public static void remove(String fileName, Context context, String key) {
    SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
            Context.MODE_PRIVATE);
    Editor editor = sp.edit();
    editor.remove(key);
    editor.apply();
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:8,代码来源:SPUtils.java


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