android.content.SharedPreferences.Editor#clear ( )源码实例Demo

下面列出了android.content.SharedPreferences.Editor#clear ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: K2AUSBKeyboard   文件: AccessManager.java
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();
	}
 
}
 
源代码2 项目: FimiX8-RE   文件: PersistentCookieStore.java
public boolean removeAll() {
    Editor prefsWriter = this.cookiePrefs.edit();
    prefsWriter.clear();
    prefsWriter.commit();
    this.cookies.clear();
    return true;
}
 
源代码3 项目: WhereYouGo   文件: FilePicker.java
@Override
protected void onPause() {
    super.onPause();
    // save the current directory
    Editor editor = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE).edit();
    editor.clear();
    if (this.currentDirectory != null) {
        editor.putString(CURRENT_DIRECTORY, this.currentDirectory.getAbsolutePath());
    }
    editor.commit();
}
 
源代码4 项目: mytracks   文件: PreferenceBackupHelperTest.java
public void testExportImportPreferences() throws Exception {
  // Populate with some initial values
  Editor editor = preferences.edit();
  editor.clear();
  editor.putBoolean("bool1", true);
  editor.putBoolean("bool2", false);
  editor.putFloat("flt1", 3.14f);
  editor.putInt("int1", 42);
  editor.putLong("long1", 123456789L);
  editor.putString("str1", "lolcat");
  ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);

  // Export it
  byte[] exported = preferenceBackupHelper.exportPreferences(preferences);

  // Mess with the previous values
  editor = preferences.edit();
  editor.clear();
  editor.putString("str2", "Shouldn't be there after restore");
  editor.putBoolean("bool2", true);
  ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);

  // Import it back
  preferenceBackupHelper.importPreferences(exported, preferences);

  assertFalse(preferences.contains("str2"));
  assertTrue(preferences.getBoolean("bool1", false));
  assertFalse(preferences.getBoolean("bool2", true));
  assertEquals(3.14f, preferences.getFloat("flt1", 0.0f));
  assertEquals(42, preferences.getInt("int1", 0));
  assertEquals(123456789L, preferences.getLong("long1", 0));
  assertEquals("lolcat", preferences.getString("str1", ""));
}
 
源代码5 项目: TowerCollector   文件: PreferencesOperations.java
public static void clearPreferences(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    Editor prefEdit = prefs.edit();
    prefEdit.clear();
    boolean cleared = prefEdit.commit();
    if (cleared) {
        Timber.d("clearPreferences(): Preferences cleared");
        Toast.makeText(context, "Preferences cleared", Toast.LENGTH_LONG).show();
    } else {
        Timber.e("clearPreferences(): Failed to clear preferences");
    }
}
 
源代码6 项目: AssistantBySDK   文件: AccessTokenKeeper.java
/**
 * 清空 SharedPreferences 中 Token信息。
 * 
 * @param context 应用程序上下文环境
 */
public static void clear(Context context) {
    if (null == context) {
        return;
    }
    
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    Editor editor = pref.edit();
    editor.clear();
    editor.commit();
}
 
源代码7 项目: browser   文件: PreferenceUtils.java
public static void clearPreference(Context context,
		final SharedPreferences p) {
	final Editor editor = p.edit();
	editor.clear();
	editor.commit();

}
 
源代码8 项目: mytracks   文件: PreferenceBackupHelper.java
/**
 * Imports all preferences from the given stream.
 * 
 * @param reader the stream to read from
 * @param preferences the shared preferences to edit
 * @throws IOException if there are any errors while reading
 */
@SuppressLint("CommitPrefEdits")
public void importPreferences(DataInputStream reader, SharedPreferences preferences)
    throws IOException {
  Editor editor = preferences.edit();
  editor.clear();

  int numPreferences = reader.readInt();
  for (int i = 0; i < numPreferences; i++) {
    String name = reader.readUTF();
    byte typeId = reader.readByte();
    readAndSetPreference(name, typeId, reader, editor);
  }
  ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
}
 
源代码9 项目: QiQuYing   文件: AccessTokenKeeper.java
/**
 * 清空 SharedPreferences 中 Token信息。
 * 
 * @param context 应用程序上下文环境
 */
public static void clear(Context context) {
    if (null == context) {
        return;
    }
    
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    Editor editor = pref.edit();
    editor.clear();
    editor.commit();
}
 
源代码10 项目: TvLauncher   文件: PageApp.java
public void saveAppMoveStatus() {

        SharedPreferences mSharedPreferences = thisActivity.getSharedPreferences("app_order", Context.MODE_PRIVATE);
        Editor editor = mSharedPreferences.edit();

        editor.clear();

        for (int i = 0; i < mAppInfos.size(); i++) {

            editor.putInt(mAppInfos.get(i).mAppName, i);

        }

        editor.apply();

    }
 
源代码11 项目: BmapLite   文件: PreferenceUtils.java
public void clear(){
    Editor ed = preference.edit();
    ed.clear();
    ed.apply();
}
 
源代码12 项目: imsdk-android   文件: PreferenceUtils.java
public static void clearPreference(Context context, final SharedPreferences p) {
    final Editor editor = p.edit();
    editor.clear();
    editor.commit();
}
 
源代码13 项目: loco-answers   文件: SpUtil.java
public void clear() {
    Editor editor = mPref.edit();
    editor.clear();
    editor.apply();
}
 
源代码14 项目: Linphone4Android   文件: PreferencesMigrator.java
private void deleteAllOldPreferences() {
	Editor editor = mOldPrefs.edit();
	editor.clear();
	editor.commit();
}
 
源代码15 项目: dcs-sdk-java   文件: PreferenceUtil.java
public static void clear(Context context, String spName) {
    SharedPreferences sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE);
    Editor editor = sp.edit();
    editor.clear();
    editSubmit(editor);
}
 
源代码16 项目: letv   文件: SharedPreferenceUtils.java
public static void clear(Context context) {
    Editor editor = context.getSharedPreferences(FILE_NAME, 0).edit();
    editor.clear();
    SharedPreferencesCompat.apply(editor);
}
 
源代码17 项目: letv   文件: SharedPreferenceUtils.java
public static void clear(Context context, String fileName) {
    Editor editor = context.getSharedPreferences(fileName, 0).edit();
    editor.clear();
    SharedPreferencesCompat.apply(editor);
}
 
源代码18 项目: VideoMeeting   文件: SimpleSharedPreference.java
public void clear() {
	Editor editor = mPref.edit();
	editor.clear();
       editor.apply();
}
 
源代码19 项目: WeGit   文件: PreferenceUtils.java
public static void clearPreference(Context context,
		final SharedPreferences p) {
	final Editor editor = p.edit();
	editor.clear();
	editor.commit();
}
 
源代码20 项目: trekarta   文件: MapPreferences.java
public void clear() {
    Editor editor = ctx.getSharedPreferences(PREFERENCES_FILE, Activity.MODE_PRIVATE).edit();
    editor.clear();
    editor.apply();
}