VCardUtils { public static String vcardToString(VCard vcard) { StringWriter writer = new StringWriter(); VCardWriter vcwriter = new VCardWriter(writer, VCardVersion.V2_1); vcwriter.getVObjectWriter().getFoldedLineWriter().setLineLength(null); String stringVCard; try { vcwriter.write(vcard); stringVCard = writer.toString(); vcwriter.close(); writer.close(); } catch (Exception e) { Log.e(TAG, "Error while converting VCard to String", e); stringVCard = null; } return stringVCard; } private  VCardUtils(); static Tuple<String, byte[]> readData(VCard vcard); static VCard writeData(String uri, String displayName, byte[] picture); static HashMap<String, String> parseMimeAttributes(String mime); static void savePeerProfileToDisk(VCard vcard, String accountId, String filename, File filesDir); static Single<VCard> saveLocalProfileToDisk(VCard vcard, String accountId, File filesDir); static VCard loadPeerProfileFromDisk(File filesDir, String filename, String accountId); static Single<VCard> loadLocalProfileFromDisk(File filesDir, String accountId); static Single<VCard> loadLocalProfileFromDiskWithDefault(File filesDir, String accountId); static String vcardToString(VCard vcard); static boolean isEmpty(VCard vCard); static final String TAG; static final String MIME_PROFILE_VCARD; static final String VCARD_KEY_MIME_TYPE; static final String VCARD_KEY_PART; static final String VCARD_KEY_OF; static final String LOCAL_USER_VCARD_NAME; }
@Test public void testVCardToString() { VCard vcard = new VCard(); vcard.addFormattedName(new FormattedName("SFL Test")); String result = VCardUtils.vcardToString(vcard); assertTrue(result.contentEquals("BEGIN:VCARD\r\n" + "VERSION:2.1\r\n" + "X-PRODID:ez-vcard 0.10.2\r\n" + "FN:SFL Test\r\n" + "END:VCARD\r\n")); }