code: @SuppressWarnings("WeakerAccess")
      public static void putOrderedStringSet(String key, Set<String> value) {
          final Editor editor = getPreferences().edit();
          int stringSetLength = 0;
          if (mPrefs.contains(key + LENGTH)) {
              // First read what the value was
              stringSetLength = mPrefs.getInt(key + LENGTH, -1);
          }
          editor.putInt(key + LENGTH, value.size());
          int i = 0;
          for (String aValue : value) {
              editor.putString(key + "[" + i + "]", aValue);
              i++;
          }
          for (; i < stringSetLength; i++) {
              // Remove any remaining values
              editor.remove(key + "[" + i + "]");
          }
          editor.apply();
      }
docs: Stores a Set of Strings, preserving the order.
  Note that this method is heavier that the native implementation {@link #putStringSet(String,
  Set)} (which does not reliably preserve the order of the Set). To preserve the order of the
  items in the Set, the Set implementation must be one that as an iterator with predictable
  order, such as {@link LinkedHashSet}.
  
  @param key   The name of the preference to modify.
  @param value The new value for the preference.
  @see #putStringSet(String, Set)
  @see #getOrderedStringSet(String, Set)