本文整理汇总了Java中android.content.SharedPreferences.Editor.clear方法的典型用法代码示例。如果您正苦于以下问题:Java Editor.clear方法的具体用法?Java Editor.clear怎么用?Java Editor.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences.Editor
的用法示例。
在下文中一共展示了Editor.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putAllBoolean
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**设置所有boolean
* @param values
*/
public static void putAllBoolean(boolean[] values){
if (values == null || values.length != KEYS.length) {
Log.e(TAG, "putAllBoolean values == null || values.length != KEYS.length >> return;");
return;
}
Editor editor = context.getSharedPreferences(APP_SETTING, Context.MODE_PRIVATE).edit();
editor.clear();
for (int i = 0; i < values.length; i++) {
editor.putBoolean(KEYS[i], values[i]);
}
editor.commit();
init(context);
}
示例2: onSharedPreferenceChanged
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (PREF_SELECTED_LANGUAGES.equals(key)) {
mLanguageSwitcher.loadLocales(sharedPreferences);
mRefreshKeyboardRequired = true;
} else if (PREF_RECORRECTION_ENABLED.equals(key)) {
mReCorrectionEnabled = sharedPreferences.getBoolean(PREF_RECORRECTION_ENABLED,
getResources().getBoolean(R.bool.default_recorrection_enabled));
}
if (PREF_KP2A_REMEMBER_AUTO_FILL.equals(key))
{
if (sharedPreferences.getBoolean(key, true) == false)
{
Log.d("KP2AK", "clearing saved field hints");
SharedPreferences savedHints = getApplicationContext().getSharedPreferences(KP2A_SAVED_FIELD_HINTS, MODE_PRIVATE);
Editor edit = savedHints.edit();
edit.clear();
edit.commit();
}
}
}
示例3: clearSharedPreference
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Clear Shared Preferences method
* @param context
*/
public static void clearSharedPreference(@NonNull Context context) {
SharedPreferences settings;
Editor editor;
settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
editor = settings.edit();
editor.clear();
editor.apply();
}
示例4: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clear(Context context, String fileName) {
SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
Context.MODE_PRIVATE);
Editor editor = sp.edit();
editor.clear();
editor.apply();
}
示例5: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 清除所有内容
*
* @param context
*/
public static void clear(Context context) {
SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE);
Editor edit = sp.edit();
edit.clear();
SharedPreferencesCompat.EditorCompat.getInstance().apply(edit);
}
示例6: clearExtras
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
protected static void clearExtras(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences("mipush_extra", 0);
long j = sharedPreferences.getLong("wake_up", 0);
Editor edit = sharedPreferences.edit();
edit.clear();
if (j > 0) {
edit.putLong("wake_up", j);
}
edit.commit();
}
示例7: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 清空 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();
}
示例8: 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();
}
}
}
示例9: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static boolean clear(Context context) {
Editor editor = getSharedPreference(context).edit();
editor.clear();
return editor.commit();
}
示例10: deleteAllOldPreferences
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private void deleteAllOldPreferences() {
Editor editor = mOldPrefs.edit();
editor.clear();
editor.commit();
}
示例11: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clear(Context context) {
Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE)
.edit();
editor.clear();
editor.commit();
}
示例12: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static boolean clear(Context context) {
Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.clear();
return editor.commit();
}
示例13: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clear(Context ctx) {
Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
}
示例14: clear
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clear(Context context) {
Editor editor = context.getSharedPreferences(FILE_NAME, 0).edit();
editor.clear();
SharedPreferencesCompat.apply(editor);
}
示例15: clearPreferences
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void clearPreferences(Context context) {
Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
editor.clear();
editor.apply();
}