2010-10-10 125 views

回答

3

我用於我的項目之一下面的解決方案。它工作完美。作爲vCard lib,我使用了cardme v.0.26,它也支持vcard版本3.0。

注意:文件名存儲在res /價值/ strings.xml中......

 /* 
     * Create file. This file has to be readable, otherwise the contact 
     * application cannot access the file via URI to read the vcard 
     * string. 
     */ 

//這個變種包含您的名片作爲一個字符串 字符串vcardString;

 FileOutputStream fOut = openFileOutput(
       getResources().getText(R.string.app_vcard_file_name) 
         .toString(), MODE_WORLD_READABLE); 
     osw = new OutputStreamWriter(fOut); 
     // write vcard string to file 
     osw.write(vcardString); 
     // ensures that all buffered bytes are written 
     osw.flush(); 
    } catch (NotFoundException e) { 
     // .. 
    } catch (IOException e) { 
     // ... 
    } finally { 
     if (osw != null) { 
      try { 
       osw.close(); 
      } catch (IOException e) { 
       // ... 
      } 
     } 
    } 
    // let the os handle the import of the vcard to the Contacts 
    // application 
    Intent i = new Intent(Intent.ACTION_VIEW); 
    i.setDataAndType(Uri.parse("file://" 
      + getFileStreamPath(
        getResources().getText(R.string.app_vcard_file_name) 
          .toString()).getAbsolutePath()), "text/x-vcard"); 
    startActivity(i); 
0

使用聯繫人VCF應用程序從sd卡/手機存儲導入聯繫人到Android手機中的聯繫人。

這裏是鏈接下載應用ContactsVcf