Reputation: 13
creating .vcf
files fore all customers stored in DB so that we can push it to mobile contacts I was able to create .vcf
file wondering how can i save this files to mobile contact automatically . if i save .vcf
file to SD card once again it asks me to save it in contacts
but i need to save contacts directly
Can i save this to Google and can i sync from there below is the code what i have done
import java.io.*;
public class Vcard{
public static void main(String[] args) throws IOException{
File f=new File("D:\\contact.vcf");
FileOutputStream fop=new FileOutputStream(f);
if(f.exists()){
String str="BEGIN:VCARD\n" +
"VERSION:4.0\n" +
"N:Gump;Forrest;;;\n" +
"FN:Forrest Gump\n"+
"ORG:Bubba Gump Shrimp Co.\n"+
"TITLE:Shrimp Man\n"+
"TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212\n"+
"EMAIL:[email protected]\n"+
"END:VCARD";
fop.write(str.getBytes());
//Now read the content of the vCard after writing data into it
BufferedReader br = null;
String sCurrentLine;
br = new BufferedReader(new FileReader("contact.vcf"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
}
//close the output stream and buffer reader
fop.flush();
fop.close();
System.out.println("The data has been written");
}
else
System.out.println("This file does not exist");
}
}
Any help will be appreciated
Upvotes: 1
Views: 932