android 使用vcard示例

  1. FileOutputStream os = null
  2. try
  3. os = VCardTest.this.openFileOutput("Android.vcf", MODE_PRIVATE); 
  4. } catch (FileNotFoundException e1) { 
  5. // TODO Auto-generated catch block 
  6. e1.printStackTrace(); 
  7. }  
  8. OutputStreamWriter writer; 
  9. try
  10. writer = new OutputStreamWriter( 
  11. os); 
  12.        VCardComposer composer = new VCardComposer(); 
  13.        //create a contact  
  14.        ContactStruct contact1 = new ContactStruct(); 
  15.        contact1.name = "Neo"
  16.        contact1.company = "The Company"
  17.        contact1.addPhone(Contacts.Phones.TYPE_MOBILE, "+123456789", null, true); 
  18.        //create vCard representation  
  19.        String vcardString; 
  20. vcardString = composer.createVCard(contact1, VCardComposer.VERSION_VCARD30_INT); 
  21.        //write vCard to the output stream 
  22.        writer.write(vcardString); 
  23.        writer.write("/n"); //add empty lines between contacts 
  24.        // repeat for other contacts  
  25.        // ...  
  26.        writer.close(); 
  27. } catch (UnsupportedEncodingException e) { 
  28. // TODO Auto-generated catch block  
  29. e.printStackTrace(); 
  30. } catch (FileNotFoundException e) { 
  31. // TODO Auto-generated catch block 
  32. e.printStackTrace(); 
  33. } catch (VCardException e) { 
  34. // TODO Auto-generated catch block  
  35. e.printStackTrace(); 
  36. } catch (IOException e) { 
  37. // TODO Auto-generated catch block 
  38. e.printStackTrace(); 
  1. FileOutputStream os = null
  2. try
  3. os = VCardTest.this.openFileOutput("Android.vcf", MODE_PRIVATE); 
  4. } catch (FileNotFoundException e1) { 
  5. // TODO Auto-generated catch block 
  6. e1.printStackTrace(); 
  7. }  
  8. OutputStreamWriter writer; 
  9. try
  10. writer = new OutputStreamWriter( 
  11. os); 
  12.        VCardComposer composer = new VCardComposer(); 
  13.        //create a contact 
  14.        ContactStruct contact1 = new ContactStruct(); 
  15.        contact1.name = "Neo"
  16.        contact1.company = "The Company"
  17.        contact1.addPhone(Contacts.Phones.TYPE_MOBILE, "+123456789", null, true); 
  18.        //create vCard representation 
  19.        String vcardString; 
  20. vcardString = composer.createVCard(contact1, VCardComposer.VERSION_VCARD30_INT); 
  21.        //write vCard to the output stream 
  22.        writer.write(vcardString); 
  23.        writer.write("/n"); //add empty lines between contacts 
  24.        // repeat for other contacts 
  25.        // ... 
  26.        writer.close(); 
  27. } catch (UnsupportedEncodingException e) { 
  28. // TODO Auto-generated catch block 
  29. e.printStackTrace(); 
  30. } catch (FileNotFoundException e) { 
  31. // TODO Auto-generated catch block 
  32. e.printStackTrace(); 
  33. } catch (VCardException e) { 
  34. // TODO Auto-generated catch block 
  35. e.printStackTrace(); 
  36. } catch (IOException e) { 
  37. // TODO Auto-generated catch block 
  38. e.printStackTrace(); 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值