當前位置: 首頁>>代碼示例>>Java>>正文


Java PreferenceManager.getDefaultSharedPreferences方法代碼示例

本文整理匯總了Java中android.preference.PreferenceManager.getDefaultSharedPreferences方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceManager.getDefaultSharedPreferences方法的具體用法?Java PreferenceManager.getDefaultSharedPreferences怎麽用?Java PreferenceManager.getDefaultSharedPreferences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.PreferenceManager的用法示例。


在下文中一共展示了PreferenceManager.getDefaultSharedPreferences方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeWallet

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public void removeWallet(String address, Context context) {
    int position = -1;
    for (int i = 0; i < mapdb.size(); i++) {
        if (mapdb.get(i).getPubKey().equalsIgnoreCase(address)) {
            position = i;
            break;
        }
    }
    if (position >= 0) {
        if (mapdb.get(position) instanceof FullWallet) // IF full wallet delete private key too
            new File(context.getFilesDir(), address.substring(2, address.length())).delete();
        mapdb.remove(position);
    }
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = preferences.edit();
    editor.remove(address);
    editor.apply();
    save(context);
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:20,代碼來源:WalletStorage.java

示例2: prefs

import android.preference.PreferenceManager; //導入方法依賴的package包/類
private static SharedPreferences prefs(Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context);
}
 
開發者ID:jakehilborn,項目名稱:speedr,代碼行數:4,代碼來源:Prefs.java

示例3: onGotIt

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public void onGotIt(View button) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor prefEditor = settings.edit();
    prefEditor.putBoolean("gotIt", true);
    prefEditor.apply();

    Intent i = new Intent(this, SettingsActivity.class);
    startActivity(i);

    //mInterstitialAd.show();
    InterstitialAd ad1 = AdManager.getAd1();
    if (ad1.isLoaded()) {
        ad1.show();
    }
    //interventie 2
    Log.d("ADS_REACH","Reached ad code");

    finish();


    //aici era interstitial initial

}
 
開發者ID:RomascuAndrei,項目名稱:BTNotifierAndroid,代碼行數:24,代碼來源:WelcomeActivity.java

示例4: getCountry

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public static String getCountry(Context context) {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  String countryOverride = prefs.getString(PreferencesActivity.KEY_SEARCH_COUNTRY, "-");
  if (countryOverride != null && !countryOverride.isEmpty() && !"-".equals(countryOverride)) {
    return countryOverride;
  }
  return getSystemCountry();
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:9,代碼來源:LocaleManager.java

示例5: getLastNotificationTimeInMillis

import android.preference.PreferenceManager; //導入方法依賴的package包/類
/**
 * Returns the last time that a notification was shown (in UNIX time)
 *
 * @param context Used to access SharedPreferences
 * @return UNIX time of when the last notification was shown
 */
public static long getLastNotificationTimeInMillis(Context context) {
    /* Key for accessing the time at which Sunshine last displayed a notification */
    String lastNotificationKey = context.getString(R.string.pref_last_notification);

    /* As usual, we use the default SharedPreferences to access the user's preferences */
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);

    /*
     * Here, we retrieve the time in milliseconds when the last notification was shown. If
     * SharedPreferences doesn't have a value for lastNotificationKey, we return 0. The reason
     * we return 0 is because we compare the value returned from this method to the current
     * system time. If the difference between the last notification time and the current time
     * is greater than one day, we will show a notification again. When we compare the two
     * values, we subtract the last notification time from the current system time. If the
     * time of the last notification was 0, the difference will always be greater than the
     * number of milliseconds in a day and we will show another notification.
     */
    long lastNotificationTime = sp.getLong(lastNotificationKey, 0);

    return lastNotificationTime;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:28,代碼來源:SunshinePreferences.java

示例6: onCreate

import android.preference.PreferenceManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    Log.d(TAG, "onCreate()");
    sPlayerService = this;
    mHandler = new Handler();
    mVideoObserver = new VideoObserver(new Handler());
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    if (Trakt.isTraktV2Enabled(this, mPreferences) && !PrivateMode.isActive()) {
        mTraktClient = new TraktService.Client(this, mTraktListener, false);
    }
    setPlayer();
    sendBroadcast(new Intent(PLAYER_SERVICE_STARTED));
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:16,代碼來源:PlayerService.java

示例7: setUp

import android.preference.PreferenceManager; //導入方法依賴的package包/類
@Before public void setUp() throws Exception {
  final SharedPreferences prefs =
      PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getContext());
  final Crypto crypto = AndroidConceal
      .get()
      .createDefaultCrypto(new SharedPrefsBackedKeyChain(
          InstrumentationRegistry.getContext(),
          CryptoConfig.KEY_256
      ));

  factory = new ConcealPreferenceFactory(crypto, prefs);
}
 
開發者ID:prolificinteractive,項目名稱:Patrons,代碼行數:13,代碼來源:ConcealIntPreferenceTest.java

示例8: setGUI

import android.preference.PreferenceManager; //導入方法依賴的package包/類
private void setGUI() {
	mFindMeButton = (Button) findViewById(R.id.action_findme);
	mLockImage = (ImageView) findViewById(R.id.imageLock);
	mGattServerSwitch = (CheckBox) findViewById(R.id.option);

	final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ProximityActivity.this);
	mGattServerSwitch.setChecked(preferences.getBoolean(PREFS_GATT_SERVER_ENABLED, true));
	mGattServerSwitch.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
			preferences.edit().putBoolean(PREFS_GATT_SERVER_ENABLED, isChecked).apply();
		}
	});
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:15,代碼來源:ProximityActivity.java

示例9: setAnonymous

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public static void setAnonymous() {
	String s = getUserId();
	if (s.indexOf("Anonymous") >= 0) {
		return;
	}
	String userId = "Anonymous_" + RandomUtil.secureRandomString();
	final SharedPreferences settings = PreferenceManager
			.getDefaultSharedPreferences(MainApp.getInstance());
	settings.edit().putString(PreferenceConstants.UserId, userId)
			.putString(userId + ":" + PreferenceConstants.AccessKey, "")
			.putString(userId + ":" + PreferenceConstants.ChatId, "")
			.putString(userId + ":" + PreferenceConstants.ChatPwd, "")
			.commit();
}
 
開發者ID:Louis19910615,項目名稱:youkes_browser,代碼行數:15,代碼來源:PreferenceUtils.java

示例10: logout

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public void logout() {
    setAuthToken(null);

    SharedPreferences settings = context.getSharedPreferences(CONSTANT_PREF_FILE, Context.MODE_PRIVATE);
    settings.edit().clear().commit();


//    MySharedPreferences.wipe(preferences);

    if (MySharedPreferences.getUserId(preferences)!= null){
        Toast.makeText(context, "userID", Toast.LENGTH_LONG).show();
    }


    if (AccessToken.getCurrentAccessToken() != null){
        LoginManager.getInstance().logOut();
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.clear();
    editor.commit();

    Intent loginIntent = new Intent(context, RegisterActivity.class);
    loginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(loginIntent);
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:28,代碼來源:Auth.java

示例11: clearLoginInfo

import android.preference.PreferenceManager; //導入方法依賴的package包/類
/**
 * Delete all the login info
 *
 * @param context needed to fetch defaultSharedPreferences
 */
public static void clearLoginInfo(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.remove(PREF_ACCESS_CODE);
    editor.remove(PREF_ACCESS_TOKEN);
    editor.remove(PREF_CODE_STATE);
    editor.remove(PREF_BASIC_USER_DETAILS);
    editor.remove(PREF_FIREBASE_USER_ID);
    editor.remove(PREF_FIREBASE_SETUP);
    editor.apply();
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:17,代碼來源:CacheUtils.java

示例12: init

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public static void init(Context context) {
    Context appContext = context.getApplicationContext();
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext);
}
 
開發者ID:dianlujitao,項目名稱:BigNews,代碼行數:5,代碼來源:PreferenceHelper.java

示例13: onReceive

import android.preference.PreferenceManager; //導入方法依賴的package包/類
@Override
public synchronized void onReceive(Context context, Intent intent) {
    if (intent == null || intent.getAction() == null || !ACTION.equals(intent.getAction()))
        return;

    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    int phoneState = manager.getCallState();
    if (phoneState != TelephonyManager.CALL_STATE_IDLE) {
        return;
    }
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    boolean isCallingOn = pref.getBoolean("calling_on", false);
    if (isCallingOn == true) {
        return;
    }
    if (pref.getBoolean("volume_key_lock", false) == true) {
        mContext = context;
        Utils.setMusicKey(mContext);
        for (int i = 0; i < interval.length; i++) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    Utils.setMusicKey(mContext);
                }
            }, interval[i]);
        }
        if (!Utils.checkAccessibilityPermission(context)) {
            Utils.showSmallToast(context, context.getString(R.string.toast_alert_enable_volkey_without_accessibility), Toast.LENGTH_LONG);
        }
    }
}
 
開發者ID:KrongKrongPadakPadak,項目名稱:mvo,代碼行數:32,代碼來源:VolumeChangeReceiver.java

示例14: FontTypePreference

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public FontTypePreference(Context context, AttributeSet attrs) {
	super(context, attrs);
	
	// figure out what is currently selected
	SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
	String font = sharedPref.getString("font", "Monospace");
	
	if (font.equals("Serif"))
		selected = 1;
	else if (font.equals("Sans Serif"))
		selected = 2;
	else  
      		selected = 0;	
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:15,代碼來源:FontTypePreference.java

示例15: getAllNotes

import android.preference.PreferenceManager; //導入方法依賴的package包/類
public static List<Note> getAllNotes(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    List<Note> noteList = new ArrayList<>();
    Map<String, ?> key = sharedPreferences.getAll();
    for (Map.Entry<String, ?> entry : key.entrySet()) {
        String savedValue = (String) entry.getValue();

        if (savedValue != null) {
            Note note = new Note(entry.getKey(), savedValue);
            noteList.add(note);
        }
    }
    return noteList;
}
 
開發者ID:PacktPublishing,項目名稱:Android-Wear-Projects,代碼行數:15,代碼來源:SharedPreferencesUtils.java


注:本文中的android.preference.PreferenceManager.getDefaultSharedPreferences方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。