Donot insert image source code when making vcard in api level 8

偶尔善良 提交于 2019-12-23 03:52:05

问题


I am making Vcard using this code , now I want In my vcard don't insert code of image , all other things will added in vcard , how I do it .... I'm using this

         String VCard = "";

         Cursor phones = getContentResolver().query(android.provider.ContactsContract.Contacts.CONTENT_URI , null,null, null, null);
         phones.moveToFirst();
         pDialog.setMax(phones.getCount());
           for(int i =0;i<phones.getCount();i++)
           {

              String lookupKey =  phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
              Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);

              AssetFileDescriptor fd;
             try 
             {
                 fd = getContentResolver().openAssetFileDescriptor(uri, "r");
                 FileInputStream fis = fd.createInputStream();
                 byte[] buf = new byte[(int) fd.getDeclaredLength()];
                 fis.read(buf);
                 VCard += new String(buf);
                 String y =String.valueOf(i);
                 publishProgress(y);
                 phones.moveToNext();                           
                 Log.d("Vcard",  VCard);
             } 
             catch (Exception e1) 
             {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
             }

         }

        try {
            FileOutputStream mFileOutputStream = new FileOutputStream(file, false);
              mFileOutputStream.write(VCard.toString().getBytes());
              mFileOutputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

回答1:


    String lookupKey = phones.getString(phones
    .getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri vcardUri = ContactsContract.Contacts.CONTENT_VCARD_URI
    .buildUpon()
    .appendQueryParameter("nophoto", String.valueOf(true))
    .build();
Uri uri = Uri.withAppendedPath(vcardUri, lookupKey);

I have modify it again,use in for loop



来源:https://stackoverflow.com/questions/15333022/donot-insert-image-source-code-when-making-vcard-in-api-level-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!