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


Java PreferenceManager.getDefaultSharedPreferences方法代码示例

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


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

示例1: showSortingDialog

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
public static void showSortingDialog(final Fragment fragment) {

        RadioDialogCallback callback = new RadioDialogCallback() {
            @Override
            public void which(int position) {
                SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(fragment.getContext());
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putInt(KEY_PREF_SORTING, position);
                editor.apply();

                SortingDialogCallback fragmentCallback = (SortingDialogCallback) fragment;
                fragmentCallback.sortBy(Sortation.parse(position));
            }
        };

        CharSequence[] items = new CharSequence[]{
                getString(fragment, R.string.sort_most_used),
                getString(fragment, R.string.sort_last_change),
                getString(fragment, R.string.sort_creation),
                getString(fragment, R.string.sort_alphabetically)
        };
        showRadioDialog(fragment.getContext(), getString(fragment, R.string.sort_dialog), items, callback);
    }
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:24,代码来源:RadioDialogs.java

示例2: onDonePressed

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onDonePressed(Fragment currentFragment) {
    super.onDonePressed(currentFragment);
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    switch (type) {
        case KEY_PREVIEW:
            editor.putBoolean(KEY_PREF_PREVIEW_INTRO_SHOWN, true);
            break;
        case KEY_TODO_LIST:
            editor.putBoolean(KEY_PREF_TODO_LIST_INTRO_SHOWN, true);
            break;
        default:
            throw new IllegalArgumentException(String.format("Unknown type %s", type));
    }
    editor.apply();

    startActivity(MainActivity.newInstace(this, type, uuid, title));
    finish();
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:21,代码来源:IntroActivity.java

示例3: isThemeNightMode

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public boolean isThemeNightMode() {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    return DisplayPreferenceUtilities.getDisplayPreference(SettingsFragment.KEY_IS_THEME_NIGHT_MODE,
            AppConstants.DISPLAY_PREFERENCES_DEFAULTS.IS_THEME_NIGHT_MODE,
            defaultSharedPreferences,

            mUserDataDBHelper);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:11,代码来源:ReadingActivity.java

示例4: saveWidgetToSharedPrefs

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
private void saveWidgetToSharedPrefs(int appWidgetId, String uuid) {
    // add widget id's to sharedPrefs
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(KEY_PREF_WIDGET_REALM_PREFIX + appWidgetId,
            sharedPreferences.getString(KEY_PREF_ACTIVE_REPO, FALLBACK_REALM));
    editor.putString(KEY_PREF_WIDGET_UUID_PREFIX + appWidgetId, uuid);
    editor.apply();
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:10,代码来源:TodoListAppWidgetConfigure.java

示例5: onDeleted

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.remove((KEY_PREF_WIDGET_REALM_PREFIX + appWidgetId));
        editor.remove(KEY_PREF_WIDGET_UUID_PREFIX + appWidgetId);
        editor.apply();
    }
    super.onDeleted(context, appWidgetIds);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:12,代码来源:TodoListAppWidgetProvider.java

示例6: setThemeNightMode

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void setThemeNightMode(boolean isDesiredThemeLight) {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    DisplayPreferenceUtilities.setDisplayPreference(SettingsFragment.KEY_IS_THEME_NIGHT_MODE,
            isDesiredThemeLight,
            defaultSharedPreferences, mUserDataDBHelper);
    restartOnThemeChange();

}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:11,代码来源:ReadingActivity.java

示例7: loadValues

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
public void loadValues(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    for (String key: mKeyList) {
        String value = sharedPreferences.getString(key, "");

        // Keep default value if the preference is not set
        if (value.isEmpty())
            continue;

        updateValue(key, value);
    }
}
 
开发者ID:rofferom,项目名称:gpstracker-android,代码行数:14,代码来源:Config.java

示例8: ensureShown

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
public static void ensureShown(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean isNotificationShown = prefs.getBoolean(SettingsFragment.KEY_NOTIFICATION_ENABLED, false);

    if (isNotificationShown) {
        ToggleNotification.show(context);
    } else {
        ToggleNotification.cancel(context);
    }
}
 
开发者ID:kz,项目名称:immersify,代码行数:11,代码来源:ToggleNotification.java

示例9: setPinchZoom

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void setPinchZoom(boolean checked) {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    DisplayPreferenceUtilities.setDisplayPreference(SettingsFragment.KEY_IS_PINCH_ZOOM_ON,
            checked,
            defaultSharedPreferences, mUserDataDBHelper);
    for (DisplayPrefChangeListener listener : displayPrefChangeListeners) {
        listener.setPinchZoom(checked);
    }
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:11,代码来源:ReadingActivity.java

示例10: setupSharedPreferences

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
private void setupSharedPreferences() {
    // Get all of the values from shared preferences to set it up
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key),
            getResources().getBoolean(R.bool.pref_show_bass_default)));
    mVisualizerView.setShowMid(sharedPreferences.getBoolean(getString(R.string.pref_show_mid_key),
            getResources().getBoolean(R.bool.pref_show_mid_default)));
    mVisualizerView.setShowTreble(sharedPreferences.getBoolean(getString(R.string.pref_show_treble_key),
            getResources().getBoolean(R.bool.pref_show_treble_default)));
    mVisualizerView.setMinSizeScale(1);
    mVisualizerView.setColor(getString(R.string.pref_color_red_value));
    // Register the listener
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:15,代码来源:VisualizerActivity.java

示例11: getDisplayZoom

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
public int getDisplayZoom() {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    return DisplayPreferenceUtilities.getDisplayPreference(
            SettingsFragment.KEY_DISPLAY_TEXT_SIZE,
            AppConstants.DISPLAY_PREFERENCES_DEFAULTS.DEFAULT_TEXT_ZOOM,
            defaultSharedPreferences, mUserDataDBHelper);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:8,代码来源:ReadingActivity.java

示例12: setupSharedPreferences

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
private void setupSharedPreferences() {
    // Get all of the values from shared preferences to set it up
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mVisualizerView.setShowBass(sharedPreferences.getBoolean(getString(R.string.pref_show_bass_key),
            getResources().getBoolean(R.bool.pref_show_bass_default)));
    mVisualizerView.setShowMid(true);
    mVisualizerView.setShowTreble(true);
    mVisualizerView.setMinSizeScale(1);
    mVisualizerView.setColor(getString(R.string.pref_color_red_value));

    // COMPLETED (3) Register the listener
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:14,代码来源:VisualizerActivity.java

示例13: getTriggeredTaskList

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
public static List<Integer> getTriggeredTaskList(Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String json = preferences.getString(context.getResources().getString(R.string.settings_triggered_task_list_key), null);
    List<Integer> tasks = new ArrayList<>();

    if(json != null) {
        try {
            Type listType = new TypeToken<List<Integer>>() {}.getType();
            Gson gson = new Gson();
            tasks = gson.fromJson(json, listType);
        } catch (Exception e) { /* Do nothing */}
    }

    return tasks;
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:16,代码来源:SharedPreferenceUtil.java

示例14: onCreate

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    setupActionBar();
    mPref = PreferenceManager.getDefaultSharedPreferences(this);
    mSetting = new Setting(this);
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:9,代码来源:SettingsActivity.java

示例15: instantiatePresenterUsing

import android.support.v7.preference.PreferenceManager; //导入方法依赖的package包/类
private static NotePresenter instantiatePresenterUsing(Fragment fragment) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(fragment.getActivity());
    String repositoryName = sharedPreferences.getString(KEY_PREF_ACTIVE_REPO, FALLBACK_REALM);
    return new NotePresenterImpl(
            ThreadExecutor.getInstance(),
            MainThreadImpl.getInstance(),
            (NotePresenter.View) fragment,
            new RepositoryImpl(repositoryName));
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:10,代码来源:NoteDialogs.java


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