code: public static void copySharedPreferences(SharedPreferences src, SharedPreferences target) {
      SharedPreferences.Editor editor = target.edit();
      for (Map.Entry<String, ?> entry : src.getAll().entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof String) {
          editor.putString(key, (String) value);
        } else if (value instanceof Set) {
          editor.putStringSet(key, (Set<String>) value);
        } else if (value instanceof Integer) {
          editor.putInt(key, (Integer) value);
        } else if (value instanceof Long) {
          editor.putLong(key, (Long) value);
        } else if (value instanceof Float) {
          editor.putFloat(key, (Float) value);
        } else if (value instanceof Boolean) {
          editor.putBoolean(key, (Boolean) value);
        }
      }
      editor.apply();
    }
docs: Copies all the values from {@code src} to {@code target}.