ez-vcard-android icon indicating copy to clipboard operation
ez-vcard-android copied to clipboard

Street and Number in wrong order

Open skauss opened this issue 4 years ago • 3 comments

Hi I am new to vcard. In Germany we use "Street Number" like "Engestrasse 2". On my phone contact on an pixel 3 I enter "Engestrasse 2" but get back "2 Engestrasse". Any idea how to solve this. US address use "323 Street" German address use "Street 123"

I read the contract like this :

cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cursor != null && cursor.getCount() > 0) {
    cursor.moveToFirst();
     for (int i = 0; i < cursor.getCount(); i++) {
          String vCardStr = getVcardAsString(cr, cursor);
          cursor.moveToNext();
         VCard vcard = Ezvcard.parse(vCardStr).first();
...
    }
}
...
public String getVcardAsString(ContentResolver cr, Cursor cursor) {
        //cursor.moveToFirst();
        String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
        AssetFileDescriptor fd;
        try {
            fd = cr.openAssetFileDescriptor(uri, "r");
            FileInputStream fis = fd.createInputStream();
            byte[] buf = new byte[(int) fis.available()];
            fis.read(buf);
            return new String(buf);
        } catch (Exception ex) {
            Log.d(TAG,"read vcard", ex);
        }
        return "";
    }

Regards

skauss avatar Jun 26 '20 06:06 skauss

Hello,

You would need to obtain the street address portion of the address property, and then convert the street address using Java string manipulation.

VCard vcard = Ezvcard.parse(vCardStr).first();
String street = vcard.getAddress().getStreetAddress();
String germanStreet = convertToGermanFormat(street);
vcard.getAddress().setStreetAddress(germanStreet);

mangstadt avatar Jun 26 '20 13:06 mangstadt

It looks for me "Street Number" is country dependent. Germany : "Street Number" US : "Number Street" And I am wondering that I the one who has the problem to rotate "Street Number" on country code ?

skauss avatar Jul 03 '20 08:07 skauss

You're the first person to bring this to my attention. :)

mangstadt avatar Jul 03 '20 12:07 mangstadt