当前位置: 移动技术网 > IT编程>移动开发>Android > Android使用vcard文件的方法简单实例

Android使用vcard文件的方法简单实例

2019年07月24日  | 移动技术网IT编程  | 我要评论

奥林巴斯生物显微镜,艾滋病毒能活多久,破茧成仙

本文实例讲述了android使用vcard文件的方法。分享给大家供大家参考,具体如下:

fileoutputstream os = null;
try {
  os = vcardtest.this.openfileoutput("android.vcf", mode_private);
} catch (filenotfoundexception e1) {
  // todo auto-generated catch block
  e1.printstacktrace();
}
outputstreamwriter writer;
try {
  writer = new outputstreamwriter(os);
  vcardcomposer composer = new vcardcomposer();
  //create a contact
  contactstruct contact1 = new contactstruct();
  contact1.name = "neo";
  contact1.company = "the company";
  contact1.addphone(contacts.phones.type_mobile, "+123456789", null, true);
  //create vcard representation
  string vcardstring;
  vcardstring = composer.createvcard(contact1, vcardcomposer.version_vcard30_int);
  //write vcard to the output stream
  writer.write(vcardstring);
  writer.write("/n"); //add empty lines between contacts
  // repeat for other contacts
  // ...
  writer.close();
} catch (unsupportedencodingexception e) {
  // todo auto-generated catch block
  e.printstacktrace();
} catch (filenotfoundexception e) {
  // todo auto-generated catch block
  e.printstacktrace();
} catch (vcardexception e) {
  // todo auto-generated catch block
  e.printstacktrace();
} catch (ioexception e) {
  // todo auto-generated catch block
  e.printstacktrace();
}

更多关于android相关内容感兴趣的读者可查看本站专题:《android文件操作技巧汇总》、《android数据库操作技巧总结》、《android编程之activity操作技巧总结》、《android编程开发之sd卡操作方法汇总》、《android开发入门与进阶教程》、《android资源操作技巧汇总》、《android视图view技巧总结》及《android控件用法总结

希望本文所述对大家android程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网