How to backup/restore a contacts in android programmatically?

风格不统一 提交于 2019-12-04 19:34:26

Use this to restore:

final MimeTypeMap mime = MimeTypeMap.getSingleton();
  String tmptype = mime.getMimeTypeFromExtension("vcf");
  final File file = new File(Environment.getExternalStorageDirectory().toString()
                    + "/contacts.vcf");
  Intent i = new Intent();
  i.setAction(android.content.Intent.ACTION_VIEW);
  i.setDataAndType(Uri.fromFile(file), "text/x-vcard");
  startActivity(i);
Akhtar
Intent mIntent = new Intent(Intent.ACTION_VIEW);
mIntent.setDataAndType(Uri.fromFile(new File(filePath)), MimeTypeMap.getSingleton().getMimeTypeFromExtension("vcf"));
startActivity(Intent.createChooser(mIntent, "Select App"));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!