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