Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:11:35+00:00 2026-06-15T15:11:35+00:00

I want to generate a .vcf file for an object which contains contact information

  • 0

I want to generate a .vcf file for an object which contains contact information like name, image, phone number, fax number, email id, address etc. This object is not added in the address book of the phone but it is stored in my application.

Once my .vcf file is generated I can send this vcard like this

Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("**generated.vcf**"), "text/x-vcard");
startActivity(i);

But I am not getting how to get this generated .vcf file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:11:37+00:00Added an answer on June 15, 2026 at 3:11 pm

    It’s actually quite easy to generate a .vcf file. Have a look at VCF format – it’s a simple text file. All you need to do is create text file and write info into it using the VCF fields. You’ll end up with something like this:

    Person p = getPerson();
    
    File vcfFile = new File(this.getExternalFilesDir(null), "generated.vcf");
    FileWriter fw = new FileWriter(vcfFile);
    fw.write("BEGIN:VCARD\r\n");
    fw.write("VERSION:3.0\r\n");
    fw.write("N:" + p.getSurname() + ";" + p.getFirstName() + "\r\n");
    fw.write("FN:" + p.getFirstName() + " " + p.getSurname() + "\r\n");
    fw.write("ORG:" + p.getCompanyName() + "\r\n");
    fw.write("TITLE:" + p.getTitle() + "\r\n");
    fw.write("TEL;TYPE=WORK,VOICE:" + p.getWorkPhone() + "\r\n");
    fw.write("TEL;TYPE=HOME,VOICE:" + p.getHomePhone() + "\r\n");
    fw.write("ADR;TYPE=WORK:;;" + p.getStreet() + ";" + p.getCity() + ";" + p.getState() + ";" + p.getPostcode() + ";" + p.getCountry() + "\r\n");
    fw.write("EMAIL;TYPE=PREF,INTERNET:" + p.getEmailAddress() + "\r\n");
    fw.write("END:VCARD\r\n");
    fw.close();
    
    Intent i = new Intent();
    i.setAction(android.content.Intent.ACTION_VIEW);
    i.setDataAndType(Uri.fromFile(vcfFile), "text/x-vcard");
    startActivity(i);
    

    (Note that this code is to be placed inside an activity. If it’s not in an activity, then replace this in front of getExternalFilesDir with an instance of Context.)

    You can have more of fewer fields, as needed. If you have ,, ; or \ characters in field values, they need to be escaped with \; to put a newline character into a value, write \\n into the file (i.e. the file itself must contain \n, the second slash is for escaping the slash in the newline).

    This code is quite crude, but it should get you started. Again, have a look at the format of VCF and go from there.

    Update: Thanks to @Michael for pointing out mistakes in my original answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want generate PDF File with an image. The image name from database and
I want to generate a Uniq Number something like TMP-0001354, TMP will be always
What i want : Generate jar file with apps version in name, Ex :
I want to generate a list of files where the name consists of ${filename}.${date}
I want to generate a bar graph from from a csv file my data
I want to generate a map of mutex elements, which probably need to be
i want to generate current date and time in a format like this Mon,
I want to generate a sequence like a multiplication table. So for a start
I want to generate a unique guid/uuid value for a property which is not
I want to generate a pretty image of my tree/graph data. I had a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.