为存储在数据库中的所有客户创建.vcf
文件,以便我们可以将其推送到移动联系人我能够创建.vcf
文件,想知道如何自动将此文件保存到移动联系人。如果我再次将.vcf
文件保存到SD卡,它会要求我将其保存在联系人中
但我需要直接保存联系人
我可以将此保存到Google,我可以从那里同步 下面是我所做的代码
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:forrestgump@example.com\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");
}
}
任何帮助将不胜感激