Source:
<code>public static void exportPreferences(Context context, OutputStream os, boolean includeGlobals, <START> Set<String> accountUuids,boolean anonymize) throws SettingsImportExportException { <END> try { XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(os, "UTF-8"); serializer.startDocument(null, Boolean.TRUE); serializer.setFeature("<LINK_0>", true); serializer.startTag(null, ROOT_ELEMENT); serializer.attribute(null, VERSION_ATTRIBUTE, Integer.toString(Settings.VERSION)); serializer.attribute(null, FILE_FORMAT_ATTRIBUTE, Integer.toString(FILE_FORMAT_VERSION)); Log.i(K9.LOG_TAG, "Exporting preferences"); Preferences preferences = Preferences.getPreferences(context); SharedPreferences storage = preferences.getPreferences(); Set<String> exportAccounts; if (accountUuids == null) { Account[] accounts = preferences.getAccounts(); exportAccounts = new HashSet<String>(); for (Account account : accounts) { exportAccounts.add(account.getUuid()); } } else { exportAccounts = accountUuids; } Map<String, Object> prefs = new TreeMap<String, Object>(storage.getAll()); if (includeGlobals) { serializer.startTag(null, GLOBAL_ELEMENT); writeSettings(serializer, prefs); serializer.endTag(null, GLOBAL_ELEMENT); } serializer.startTag(null, ACCOUNTS_ELEMENT); for (String accountUuid : exportAccounts) { Account account = preferences.getAccount(accountUuid); writeAccount(serializer, account, prefs, anonymize); } serializer.endTag(null, ACCOUNTS_ELEMENT); serializer.endTag(null, ROOT_ELEMENT); serializer.endDocument(); serializer.flush(); } catch (Exception e) { throw new SettingsImportExportException(e.getLocalizedMessage(), e); } }</code><technical_language>Eek, anonymize scattered this file hard track anonymized. create a Set of anonymous fields writeElement() figure out if anonymize not. java private static final Set<String> privateFields = ImmutableSet<String>.of(HOST_ELEMENT, POST_ELEMENT, etc); // In writeElement() if(privateFields.contains(elementName)) { = ANNON_STRING; }</technical_language>

Target:
public static void exportPreferences(Context context, OutputStream os, boolean includeGlobals, Set<String> accountUuids,boolean anonymize) throws SettingsImportExportException { if(anonymize) { privateFields = new HashSet<String>(Arrays.asList(USERNAME_ELEMENT, PASSWORD_ELEMENT, NAME_ELEMENT, EMAIL_ELEMENT, HOST_ELEMENT, PORT_ELEMENT)); } else { privateFields = new HashSet<String>(); } try { XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(os, "UTF-8"); serializer.startDocument(null, Boolean.TRUE); serializer.setFeature("<LINK_0>", true); serializer.startTag(null, ROOT_ELEMENT); serializer.attribute(null, VERSION_ATTRIBUTE, Integer.toString(Settings.VERSION)); serializer.attribute(null, FILE_FORMAT_ATTRIBUTE, Integer.toString(FILE_FORMAT_VERSION)); Log.i(K9.LOG_TAG, "Exporting preferences"); Preferences preferences = Preferences.getPreferences(context); SharedPreferences storage = preferences.getPreferences(); Set<String> exportAccounts; if (accountUuids == null) { Account[] accounts = preferences.getAccounts(); exportAccounts = new HashSet<String>(); for (Account account : accounts) { exportAccounts.add(account.getUuid()); } } else { exportAccounts = accountUuids; } Map<String, Object> prefs = new TreeMap<String, Object>(storage.getAll()); if (includeGlobals) { serializer.startTag(null, GLOBAL_ELEMENT); writeSettings(serializer, prefs); serializer.endTag(null, GLOBAL_ELEMENT); } serializer.startTag(null, ACCOUNTS_ELEMENT); for (String accountUuid : exportAccounts) { Account account = preferences.getAccount(accountUuid); writeAccount(serializer, account, prefs); } serializer.endTag(null, ACCOUNTS_ELEMENT); serializer.endTag(null, ROOT_ELEMENT); serializer.endDocument(); serializer.flush(); } catch (Exception e) { throw new SettingsImportExportException(e.getLocalizedMessage(), e); } }