本文整理汇总了Java中android.preference.PreferenceManager.setSharedPreferencesName方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceManager.setSharedPreferencesName方法的具体用法?Java PreferenceManager.setSharedPreferencesName怎么用?Java PreferenceManager.setSharedPreferencesName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceManager
的用法示例。
在下文中一共展示了PreferenceManager.setSharedPreferencesName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefStore.setLocale(this);
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(PrefStore.getSettingsSharedName());
// Restore from conf file
PrefStore.restoreSettings(this);
addPreferencesFromResource(R.xml.settings);
initSummaries(getPreferenceScreen());
}
示例2: setDriveIdFromOffice
import android.preference.PreferenceManager; //导入方法依赖的package包/类
public void setDriveIdFromOffice(String office){
PreferenceManager prefMgr = getPreferenceManager();
String spf = prefMgr.getSharedPreferencesName();
prefMgr.setSharedPreferencesName(SyncToDriveService.PREFERENCES_NAME);
String officeDriveIDkey = SyncToDriveService.PREF_DRIVE_ID + ":" + office;
String sDriveID = prefMgr.getSharedPreferences().getString(officeDriveIDkey, "");
prefMgr.getSharedPreferences().edit()
.putString(SyncToDriveService.PREF_DRIVE_ID, sDriveID)
.apply();
prefMgr.setSharedPreferencesName(spf);
}
示例3: onCreate
import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Make sure to call this since we're using a different
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(SyncToDriveService.PREFERENCES_NAME);
addPreferencesFromResource(R.xml.pref_sync);
setHasOptionsMenu(true);
SetDriveStringDetails();
Preference disconButton = findPreference("clear_drive_data");
if(disconButton != null){
disconButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener(){
@Override
public boolean onPreferenceClick(Preference p){
Log.v("SETTING", "Clear Google Login");
ClearDriveID();
// Need to call service
Intent i = new Intent(getActivity(), SyncToDriveService.class).putExtra("clear_drive_data", true);
getActivity().startService(i);
return true;
}
});
}
}
示例4: SetDriveStringDetails
import android.preference.PreferenceManager; //导入方法依赖的package包/类
private void SetDriveStringDetails(){
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(SyncToDriveService.PREFERENCES_NAME);
findPreference(SyncToDriveService.PREF_DRIVE_ID).setSummary(
prefMgr.getSharedPreferences().getString(SyncToDriveService.PREF_DRIVE_ID, "none"));
findPreference(SyncToDriveService.PREF_DRIVE_ID_LAST_SAVE_TIME).setSummary(
prefMgr.getSharedPreferences().getString(SyncToDriveService.PREF_DRIVE_ID_LAST_SAVE_TIME, "never"));
if (prefMgr.getSharedPreferences().getString(SyncToDriveService.PREF_DRIVE_ID, "").length() < 1){
findPreference("clear_drive_data").setEnabled(false);
}
}
示例5: getCurrentOfficeSaveIDPref
import android.preference.PreferenceManager; //导入方法依赖的package包/类
public String getCurrentOfficeSaveIDPref(){
PreferenceManager prefMgr = getPreferenceManager();
String spf = prefMgr.getSharedPreferencesName();
prefMgr.setSharedPreferencesName(WeightRecorder.PREFERENCES_NAME);
String sOffice = prefMgr.getSharedPreferences().getString(WeightRecorder.PREF_OFFICE, WeightRecorder.DEFAULT_OFFICE);
prefMgr.setSharedPreferencesName(spf);
return SyncToDriveService.PREF_DRIVE_ID + ":" + sOffice;
}
示例6: ClearDriveID
import android.preference.PreferenceManager; //导入方法依赖的package包/类
public void ClearDriveID(){
Log.v("SETTINGS", "Clearing Drive ID");
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(SyncToDriveService.PREFERENCES_NAME);
SharedPreferences mSharedPreferences = prefMgr.getSharedPreferences();
mSharedPreferences.edit()
.putBoolean(SyncToDriveService.PREF_USE_GOOGLE_DRIVE, false)
.apply();
mSharedPreferences.edit()
.putString(SyncToDriveService.PREF_DRIVE_ID, "")
.apply();
mSharedPreferences.edit()
.putString(getCurrentOfficeSaveIDPref(), "")
.apply();
// Commit here so that we make sure these items are changed before
// we read the strings again and update the settings page
mSharedPreferences.edit()
.putString(SyncToDriveService.PREF_DRIVE_ID_LAST_SAVE_TIME, "")
.commit();
SetDriveStringDetails();
}
示例7: onCreate
import android.preference.PreferenceManager; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager manager = getPreferenceManager();
manager.setSharedPreferencesName(PREFS_COMMON); // configure preferences
addPreferencesFromResource(R.layout.prefs_brightness);
CheckBoxPreference checkbox = (CheckBoxPreference) findPreference(PREF_LIGHT_SENSOR);
checkbox.setOnPreferenceClickListener(this);
}
示例8: onCreate
import android.preference.PreferenceManager; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager manager = getPreferenceManager();
manager.setSharedPreferencesName(PREFS_COMMON);
addPreferencesFromResource(mLayoutResource);
}
示例9: getSharedPreferences
import android.preference.PreferenceManager; //导入方法依赖的package包/类
public static SharedPreferences getSharedPreferences(PreferenceManager preferenceManager, String prefName) {
if (!TextUtils.isEmpty(prefName)) {
preferenceManager.setSharedPreferencesName(prefName);
}
preferenceManager.setSharedPreferencesMode(Context.MODE_WORLD_READABLE);
return preferenceManager.getSharedPreferences();
}
示例10: onCreate
import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefStore.setLocale(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(PrefStore.getPropertiesSharedName());
// Restore from conf file if open from main activity
if (getIntent().getBooleanExtra("restore", false)) {
PrefStore.restoreProperties(this);
}
Bundle b = getIntent().getExtras();
int pref = 0;
if (b != null)
pref = b.getInt("pref");
switch (pref) {
case 1:
addPreferencesFromResource(R.xml.properties_ssh);
break;
case 2:
addPreferencesFromResource(R.xml.properties_vnc);
break;
case 3:
addPreferencesFromResource(R.xml.properties_x11);
break;
case 4:
addPreferencesFromResource(R.xml.properties_fb);
break;
case 5:
addPreferencesFromResource(R.xml.properties_run_parts);
break;
case 6:
addPreferencesFromResource(R.xml.properties_sysv);
break;
default:
addPreferencesFromResource(R.xml.properties);
}
initSummaries(getPreferenceScreen());
}
示例11: setupPreferenceManager
import android.preference.PreferenceManager; //导入方法依赖的package包/类
/**
* Setup {@code pm} to use global unique filename and global access mode.
* You must use this method if you let the user change preferences via UI
* (such as {@link PreferenceActivity}, {@link PreferenceFragment}...).
*
* @param pm
* {@link PreferenceManager}.
* @since v4.9 beta
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void setupPreferenceManager(PreferenceManager pm) {
pm.setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
pm.setSharedPreferencesName(genPreferenceFilename());
}