Java Code Examples for androidx.preference.PreferenceManager#setSharedPreferencesName()
The following examples show how to use
androidx.preference.PreferenceManager#setSharedPreferencesName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalBackupStorageSettingsFragment.java From SAI with GNU General Public License v3.0 | 6 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { mProvider = LocalBackupStorageProvider.getInstance(requireContext()); mDemoMeta = Objects.requireNonNull(PackageMeta.forPackage(requireContext(), requireContext().getPackageName())); PreferenceManager prefManager = getPreferenceManager(); prefManager.setSharedPreferencesName(LocalBackupStoragePrefConstants.PREFS_NAME); addPreferencesFromResource(R.xml.preferences_lbs); mBackupNameFormatPref = findPreference("backup_file_name_format"); updateBackupNameFormatSummary(); mBackupNameFormatPref.setOnPreferenceClickListener((p) -> { NameFormatBuilderDialogFragment.newInstance(mProvider.getBackupNameFormat()).show(getChildFragmentManager(), "backup_name_format_builder"); return true; }); mBackupDirPref = findPreference(LocalBackupStoragePrefConstants.KEY_BACKUP_DIR_URI); updateBackupDirSummary(); mBackupDirPref.setOnPreferenceClickListener(p -> { UriDirectoryPickerDialogFragment.newInstance(requireContext()).show(getChildFragmentManager(), "backup_dir"); return true; }); }
Example 2
Source File: DownloadDetailsSettingsFragment.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { final Module module = mActivity.getModule(); if (module == null) return; final String packageName = module.packageName; PreferenceManager prefManager = getPreferenceManager(); prefManager.setSharedPreferencesName("module_settings"); PrefixedSharedPreferences.injectToPreferenceManager(prefManager, module.packageName); addPreferencesFromResource(R.xml.module_prefs); SharedPreferences prefs = requireActivity().getSharedPreferences("module_settings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); if (prefs.getBoolean("no_global", true)) { for (Map.Entry<String, ?> k : prefs.getAll().entrySet()) { if (Objects.requireNonNull(prefs.getString(k.getKey(), "")).equals("global")) { editor.putString(k.getKey(), "").apply(); } } editor.putBoolean("no_global", false).apply(); } Preference pref = findPreference("release_type"); Objects.requireNonNull(pref).setOnPreferenceChangeListener( (preference, newValue) -> { RepoLoader.getInstance().setReleaseTypeLocal(packageName, (String) newValue); return true; }); }
Example 3
Source File: SettingsActivity.java From esp-idf-provisioning-android with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { PreferenceManager prefMgr = getPreferenceManager(); prefMgr.setSharedPreferencesName(AppConstants.ESP_PREFERENCES); setPreferencesFromResource(R.xml.preferences, rootKey); }
Example 4
Source File: ProfileOrParentFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { // Check arguments- see whether we're supposed to run on behalf of the parent profile. final Bundle arguments = getArguments(); if (arguments != null) { mParentInstance = arguments.getBoolean(EXTRA_PARENT_PROFILE, false); } mAdminComponent = DeviceAdminReceiver.getComponentName(getActivity()); // Get a device policy manager for the current user. mDevicePolicyManager = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE); // Store whether we are the profile owner for faster lookup. mProfileOwner = mDevicePolicyManager.isProfileOwnerApp(getActivity().getPackageName()); mDeviceOwner = mDevicePolicyManager.isDeviceOwnerApp(getActivity().getPackageName()); if (mParentInstance) { mDevicePolicyManager = mDevicePolicyManager.getParentProfileInstance(mAdminComponent); } // Put at last to make sure all initializations above are done before subclass's // onCreatePreferences is called. super.onCreate(savedInstanceState); // Switch to parent profile if we are running on their behalf. // This needs to be called after super.onCreate because preference manager is set up // inside super.onCreate. if (mParentInstance) { final PreferenceManager pm = getPreferenceManager(); pm.setSharedPreferencesName(pm.getSharedPreferencesName() + TAG_PARENT); } }
Example 5
Source File: CommCarePreferenceFragment.java From commcare-android with Apache License 2.0 | 5 votes |
@CallSuper protected void initPrefsFile() { if (isPersistentAppPreference()) { PreferenceManager prefMgr = getPreferenceManager(); prefMgr.setSharedPreferencesName((CommCareApplication.instance().getCurrentApp().getPreferencesFilename())); } }
Example 6
Source File: BasePreferenceFragment.java From XMiTools with GNU General Public License v3.0 | 4 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { PreferenceManager pm = getPreferenceManager(); pm.setSharedPreferencesName(AppConst.X_MIUI_CLOCK_PREFS_NAME); }