當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。