@Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key.equalsIgnoreCase(getString(R.string.pref_keys_location))) {
      // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
      SharedPreferences.Editor editor = sharedPreferences.edit();
      editor.remove(getString(R.string.pref_location_latitude));
      editor.remove(getString(R.string.pref_location_longitude));
      editor.commit();

      // Remove attributions for our any PlacePicker locations.
      if (mAttribution != null) {
        mAttribution.setVisibility(View.GONE);
      }

      Utility.resetLocationStatus(this);
      SunshineSyncAdapter.syncImmediately(this);
    } else if (key.equalsIgnoreCase(getString(R.string.pref_keys_location_key_status))) {
      // our location status has changed.  Update the summary accordingly
      Preference locationPreference = findPreference(getString(R.string.pref_keys_location));
      bindPreferenceSummaryToValue(locationPreference);
    } else if (key.equals(getString(R.string.pref_keys_unit_type))) {
      // units have changed. update lists of weather entries accordingly
      getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    } else if (key.equals(getString(R.string.pref_key_icon))) {
      // art pack have changed. update lists of weather entries accordingly
      getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
  }
 /** Remove Token, Secret from preferences */
 private void disconnectTwitter() {
   SharedPreferences.Editor editor = mSharedPreferences.edit();
   editor.remove(Const.PREF_KEY_TOKEN);
   editor.remove(Const.PREF_KEY_SECRET);
   getTweetButton.setEnabled(false);
   editor.commit();
 }
Esempio n. 3
0
 public static void clearDropboxAccessTokenPair(Context context) {
   SharedPreferences settings = context.getSharedPreferences(DROPBOX_PREFS, Context.MODE_PRIVATE);
   SharedPreferences.Editor editor = settings.edit();
   editor.remove(DROPBOX_KEY);
   editor.remove(DROPBOX_SECRET);
   editor.commit();
 }
 public void onClickView(View v) {
   SharedPreferences.Editor editor = spre.edit();
   int id = v.getId();
   switch (id) {
     case R.id.button_shared_1: // 获取宿主程序缓存的数据
       String str = spre.getString("Test_Shared", "默认值");
       MyToast.show(this, str);
       break;
     case R.id.button_shared_11: // 清空宿主程序缓存的数据
       editor.remove("Test_Shared");
       editor.commit();
       break;
     case R.id.button_shared_2: // 缓存插件《PluginCode》文本
       editor.putString("Plugin_Data", "PluginCode");
       editor.commit();
       break;
     case R.id.button_shared_3: // 读取插件缓存文本
       String data = spre.getString("Plugin_Data", "默认值");
       MyToast.show(this, data);
       break;
     case R.id.button_shared_4: // 清空插件缓存文本
       editor.remove("Plugin_Data");
       editor.commit();
       break;
   }
 }
Esempio n. 5
0
  public static void save(
      final Context context,
      final String oldHost,
      final String newHost,
      final int port,
      final String password) {

    SharedPreferences sharedPrefs = getPrefs(context);
    // save values
    SharedPreferences.Editor editor = sharedPrefs.edit();
    // get available hosts (except this host)
    ArrayList<String> hosts = getSavedHosts(context);
    hosts.remove(oldHost);
    // delete old values in case host changed
    editor.remove(prefPort(oldHost));
    editor.remove(prefPassword(oldHost));
    // add new values
    editor.putString(CURRENT_HOST, newHost);
    editor.putInt(prefPort(newHost), port);
    editor.putString(prefPassword(newHost), password);
    // build new string of available hosts
    if (!hosts.contains(newHost)) hosts.add(newHost);
    String newHostString = "";
    for (String s : hosts) newHostString += "=" + s;
    editor.putString(AVAILABLE_HOSTS, newHostString.substring(1));
    Log.d(Storage.class.getSimpleName(), "new host list {" + newHostString.substring(1) + "}");
    // save and exit
    editor.commit();
  }
  /** Remove Token, Secret from preferences */
  private void disconnectTwitter() {
    SharedPreferences.Editor editor = mSharedPreferences.edit();
    editor.remove(Const.PREF_KEY_TOKEN);
    editor.remove(Const.PREF_KEY_SECRET);

    editor.commit();
  }
Esempio n. 7
0
 private void writeToSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   editor.putLong(Stopwatches.PREF_START_TIME, mStartTime);
   editor.putLong(Stopwatches.PREF_ACCUM_TIME, mAccumulatedTime);
   editor.putInt(Stopwatches.PREF_STATE, mState);
   if (mLapsAdapter != null) {
     long[] laps = mLapsAdapter.getLapTimes();
     if (laps != null) {
       editor.putInt(Stopwatches.PREF_LAP_NUM, laps.length);
       for (int i = 0; i < laps.length; i++) {
         String key = Stopwatches.PREF_LAP_TIME + Integer.toString(laps.length - i);
         editor.putLong(key, laps[i]);
       }
     }
   }
   if (mState == Stopwatches.STOPWATCH_RUNNING) {
     editor.putLong(Stopwatches.NOTIF_CLOCK_BASE, mStartTime - mAccumulatedTime);
     editor.putLong(Stopwatches.NOTIF_CLOCK_ELAPSED, -1);
     editor.putBoolean(Stopwatches.NOTIF_CLOCK_RUNNING, true);
   } else if (mState == Stopwatches.STOPWATCH_STOPPED) {
     editor.putLong(Stopwatches.NOTIF_CLOCK_ELAPSED, mAccumulatedTime);
     editor.putLong(Stopwatches.NOTIF_CLOCK_BASE, -1);
     editor.putBoolean(Stopwatches.NOTIF_CLOCK_RUNNING, false);
   } else if (mState == Stopwatches.STOPWATCH_RESET) {
     editor.remove(Stopwatches.NOTIF_CLOCK_BASE);
     editor.remove(Stopwatches.NOTIF_CLOCK_RUNNING);
     editor.remove(Stopwatches.NOTIF_CLOCK_ELAPSED);
   }
   editor.putBoolean(Stopwatches.PREF_UPDATE_CIRCLE, false);
   editor.apply();
 }
 public static void clearSavedSourceApplicationInfoFromDisk() {
   SharedPreferences sharedPreferences =
       PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext());
   SharedPreferences.Editor editor = sharedPreferences.edit();
   editor.remove(CALL_APPLICATION_PACKAGE_KEY);
   editor.remove(OPENED_BY_APP_LINK_KEY);
   editor.apply();
 }
Esempio n. 9
0
 public static void removeUser(Context context) {
   SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
   SharedPreferences.Editor editor = preferences.edit();
   editor.remove("id");
   editor.remove("login");
   editor.remove("password");
   editor.commit();
 }
  /**
   * Removes the Authentication for the current user.
   *
   * @param context The current Android context.
   */
  public static void clearAccount(Context context) {

    SharedPreferences prefs = context.getSharedPreferences("singly", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.remove(ACCESS_TOKEN);
    editor.remove(ACCOUNT);
    editor.commit();
  }
Esempio n. 11
0
 /** 退出登录 */
 public void quitLogin() {
   SharedPreferences preferences =
       this.getSharedPreferences(Config.USER_DATA, Activity.MODE_PRIVATE);
   SharedPreferences.Editor editor = preferences.edit();
   editor.remove(Config.OAUTH_TOKEN);
   editor.remove(Config.OAUTH_TOKEN_SECRET);
   editor.remove(Config.UID);
   editor.commit();
 }
 // Clears local user Database
 public void clearUserData() {
   SharedPreferences.Editor spEditor = userLocalDatabase.edit();
   spEditor.remove("username");
   spEditor.remove("password");
   spEditor.remove("email");
   spEditor.remove("lastname");
   spEditor.remove("firstname");
   spEditor.apply();
 }
Esempio n. 13
0
  private void bilgileriSil() {

    SharedPreferences.Editor editor = mSharedPreferences.edit();
    editor.remove("name");
    editor.remove("surname");
    editor.remove("age");
    editor.remove("weight");
    editor.remove("arabasiVarmi");
    editor.commit();
  }
Esempio n. 14
0
    public void logout() {
      this.sessionToken = null;
      this.userId = null;

      SharedPreferences.Editor edit = sharedPreferences.edit();
      edit.remove(SESSION_TOKEN);
      edit.remove(USER_ID);

      edit.apply();
    }
Esempio n. 15
0
 public void logout() {
   SharedPreferences.Editor edit = mPrefs.edit();
   edit.remove(CFID);
   edit.remove(CFTOKEN);
   edit.remove(JOURNAL_ID);
   mCfid = null;
   mCftoken = null;
   mJournalId = null;
   edit.commit();
 }
Esempio n. 16
0
 public void delete(Context context) {
   SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
   SharedPreferences.Editor editor = sharedPreferences.edit();
   Set<String> idSet = sharedPreferences.getStringSet(REBOOT_IDS, new HashSet<String>());
   idSet.remove(Integer.toString(mId));
   editor.putStringSet(REBOOT_IDS, idSet);
   editor.remove(Integer.toString(mId) + REBOOT_TIME_HOUR);
   editor.remove(Integer.toString(mId) + REBOOT_TIME_MINUTE);
   editor.remove(Integer.toString(mId) + REBOOT_ACTIVE);
   editor.commit();
 }
 public void clearUserPreferencesData() {
   SharedPreferences prefs = OpenMRS.getInstance().getOpenMRSSharedPreferences();
   SharedPreferences.Editor editor = prefs.edit();
   editor.putString(
       ApplicationConstants.LAST_SESSION_TOKEN,
       prefs.getString(ApplicationConstants.SESSION_TOKEN, ApplicationConstants.EMPTY_STRING));
   editor.remove(ApplicationConstants.SESSION_TOKEN);
   editor.remove(ApplicationConstants.AUTHORIZATION_TOKEN);
   clearCurrentLoggedInUserInfo();
   editor.commit();
 }
  public void clear() {
    // Clear cookies from local store
    cookies.clear();

    // Clear cookies from persistent store
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
    for (String name : cookies.keySet()) {
      prefsWriter.remove(COOKIE_NAME_PREFIX + name);
    }
    prefsWriter.remove(COOKIE_NAME_STORE);
    prefsWriter.commit();
  }
 /**
  * Sets whether the device was successfully registered in the server side.
  *
  * @param flag True if registration was successful, false otherwise
  * @param gcmId True if registration was successful, false otherwise
  */
 public void setRegisteredOnServer(Location location, boolean flag, String gcmId) {
   Ln.d("Setting registered on server status as: " + flag);
   SharedPreferences.Editor editor = preferences.edit();
   if (flag) {
     editor.putLong(makePushKey(location), new Date().getTime());
     editor.putString(PROPERTY_REG_ID, gcmId);
   } else {
     editor.remove(PROPERTY_REG_ID);
     editor.remove(makePushKey(location));
   }
   save(editor);
 }
 protected void signOutOfAccount() { // logout user completely, remove all login information
   SharedPreferences settings = getSharedPreferences("PosseUpData", MODE_PRIVATE);
   SharedPreferences.Editor editor = settings.edit();
   editor.remove("access_token");
   editor.remove("email");
   editor.remove("username");
   editor.remove("profileImageURL");
   editor.apply();
   AccessToken accessToken = AccessToken.getCurrentAccessToken();
   if (accessToken != null) {
     LoginManager.getInstance().logOut();
   }
 }
Esempio n. 21
0
  // Helper to remove the snooze preference. Do not use clear because that
  // will erase the clock preferences. Also clear the snooze notification in
  // the window shade.
  private static void clearSnoozePreference(final Context context, final SharedPreferences prefs) {
    final int alarmId = prefs.getInt(PREF_SNOOZE_ID, -1);
    if (alarmId != -1) {
      NotificationManager nm =
          (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      nm.cancel(alarmId);
    }

    final SharedPreferences.Editor ed = prefs.edit();
    ed.remove(PREF_SNOOZE_ID);
    ed.remove(PREF_SNOOZE_TIME);
    ed.apply();
  };
Esempio n. 22
0
 public void clear() {
   this.mCookies.clear();
   SharedPreferences.Editor localEditor = this.mCookiePrefs.edit();
   Iterator localIterator = this.mCookies.keySet().iterator();
   while (localIterator.hasNext()) {
     String str = (String) localIterator.next();
     localEditor.remove("cookie_" + str);
   }
   localEditor.remove("names");
   localEditor.commit();
   CookieManager.getInstance().removeAllCookie();
   CookieSyncManager.getInstance().sync();
 }
Esempio n. 23
0
  public void logoutFromTwitter() {
    // Clear the shared preferences
    SharedPreferences.Editor e = mSharedPreferences.edit();
    e.remove(PREF_KEY_ACCESS_TOKEN);
    e.remove(PREF_KEY_ACCESS_SECRET);
    e.remove(PREF_KEY_TWITTER_LOGIN);
    e.commit();

    // After this take the appropriate action
    // I am showing the hiding/showing buttons again
    // You might not needed this code

  }
Esempio n. 24
0
 /** Clears the persistent data of stopwatch (start time, state, laps, etc...). */
 public static void clearSwSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   editor.remove(Stopwatches.PREF_START_TIME);
   editor.remove(Stopwatches.PREF_ACCUM_TIME);
   editor.remove(Stopwatches.PREF_STATE);
   int lapNum = prefs.getInt(Stopwatches.PREF_LAP_NUM, Stopwatches.STOPWATCH_RESET);
   for (int i = 0; i < lapNum; i++) {
     String key = Stopwatches.PREF_LAP_TIME + Integer.toString(i);
     editor.remove(key);
   }
   editor.remove(Stopwatches.PREF_LAP_NUM);
   editor.apply();
 }
Esempio n. 25
0
  private static void clearAllSnoozePreferences(
      final Context context, final SharedPreferences prefs) {
    NotificationManager nm =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final Set<String> snoozedIds = prefs.getStringSet(PREF_SNOOZE_IDS, new HashSet<String>());
    final SharedPreferences.Editor ed = prefs.edit();
    for (String snoozeId : snoozedIds) {
      nm.cancel(Integer.parseInt(snoozeId));
      ed.remove(getAlarmPrefSnoozeTimeKey(snoozeId));
    }

    ed.remove(PREF_SNOOZE_IDS);
    ed.apply();
  }
Esempio n. 26
0
 public void clear() {
   this.cookies.clear();
   SharedPreferences.Editor localEditor = this.cookiePrefs.edit();
   Iterator localIterator = this.cookies.keySet().iterator();
   for (; ; ) {
     if (!localIterator.hasNext()) {
       localEditor.remove("names");
       localEditor.commit();
       return;
     }
     String str = (String) localIterator.next();
     localEditor.remove("cookie_" + str);
   }
 }
Esempio n. 27
0
 public void deleteFromSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   String key = PREF_TIMER_ID + Integer.toString(mTimerId);
   String id = Integer.toString(mTimerId);
   editor.remove(key);
   key = PREF_START_TIME + id;
   editor.remove(key);
   key = PREF_TIME_LEFT + id;
   editor.remove(key);
   key = PREF_ORIGINAL_TIME + id;
   editor.remove(key);
   key = PREF_SETUP_TIME + id;
   editor.remove(key);
   key = PREF_STATE + id;
   editor.remove(key);
   Set<String> timersList = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>());
   timersList.remove(id);
   editor.putStringSet(PREF_TIMERS_LIST, timersList);
   key = PREF_LABEL + id;
   editor.remove(key);
   key = PREF_DELETE_AFTER_USE + id;
   editor.remove(key);
   editor.commit();
   // dumpTimersFromSharedPrefs(prefs);
 }
Esempio n. 28
0
    /**
     * Callback invoked when there is any change to any SubscriptionInfo. Typically this method
     * would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
     */
    @Override
    public void onSubscriptionsChanged() {
      if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
      // Set the network type, in case the radio does not restore it.
      int subId = mPhoneBase.getSubId();
      if (mPreviousSubId.getAndSet(subId) != subId) {
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
          Context context = mPhoneBase.getContext();
          int networkType = PhoneFactory.calculatePreferredNetworkType(context, subId);
          mCi.setPreferredNetworkType(networkType, null);

          mPhoneBase.notifyCallForwardingIndicator();

          boolean skipRestoringSelection =
              context
                  .getResources()
                  .getBoolean(com.android.internal.R.bool.skip_restoring_network_selection);
          if (!skipRestoringSelection) {
            // restore the previous network selection.
            mPhoneBase.restoreSavedNetworkSelection(null);
          }

          mPhoneBase.setSystemProperty(
              TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
              ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));

          if (mSpnUpdatePending) {
            mSubscriptionController.setPlmnSpn(
                mPhoneBase.getPhoneId(), mCurShowPlmn, mCurPlmn, mCurShowSpn, mCurSpn);
            mSpnUpdatePending = false;
          }

          // Remove old network selection sharedPreferences since SP key names are now
          // changed to include subId. This will be done only once when upgrading from an
          // older build that did not include subId in the names.
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
          String oldNetworkSelectionName = sp.getString(PhoneBase.NETWORK_SELECTION_NAME_KEY, "");
          String oldNetworkSelection = sp.getString(PhoneBase.NETWORK_SELECTION_KEY, "");
          if (!TextUtils.isEmpty(oldNetworkSelectionName)
              || !TextUtils.isEmpty(oldNetworkSelection)) {
            SharedPreferences.Editor editor = sp.edit();
            editor.putString(PhoneBase.NETWORK_SELECTION_NAME_KEY + subId, oldNetworkSelectionName);
            editor.putString(PhoneBase.NETWORK_SELECTION_KEY + subId, oldNetworkSelection);
            editor.remove(PhoneBase.NETWORK_SELECTION_NAME_KEY);
            editor.remove(PhoneBase.NETWORK_SELECTION_KEY);
            editor.commit();
          }
        }
      }
    }
Esempio n. 29
0
  static void clearCookies(RedditSettings settings, HttpClient client, Context context) {
    settings.setRedditSessionCookie(null);

    RedditIsFunHttpClientFactory.getCookieStore().clear();
    CookieSyncManager.getInstance().sync();

    SharedPreferences sessionPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = sessionPrefs.edit();
    editor.remove("reddit_sessionValue");
    editor.remove("reddit_sessionDomain");
    editor.remove("reddit_sessionPath");
    editor.remove("reddit_sessionExpiryDate");
    editor.commit();
  }
Esempio n. 30
0
  public void LogoutTwitter() {

    SharedPreferences pref = context.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.remove(Const.PREF_KEY_ACCESS_TOKEN);
    editor.remove(Const.PREF_KEY_ACCESS_TOKEN_SECRET);
    editor.commit();

    if (mTwitter != null) {
      mTwitter.shutdown();
    }

    Toast.makeText(activity, "Successfully logged out", Toast.LENGTH_SHORT).show();
  }