0

Can someone provide me the code to import contacts from sdcard to android phone.? I was looking into this link: Export the Contacts as VCF file however, its just the opposite of what i want. Please help.

Community
  • 1
  • 1
scooby
  • 493
  • 11
  • 31

1 Answers1

0

In order to Import Contacts you just need to call inbuilt Intent of Android ....

 private void restoreContact(){
   if(android.os.Build.VERSION.SDK_INT < 11){
      try{
           Intent i = new Intent();
           i.setComponent(new ComponentName("com.android.contacts","com.android.contacts.ImportVCardActivity"));
           startActivity(i);
       } catch(Exception e){
           try {
               Intent i = new Intent();
               i.setComponent(new ComponentName("com.sonyericsson.contacts","com.sonyericsson.contacts.contactlist.ImportVCardActivity"));
               startActivity(i);
           }
           catch (Exception ex)
           {
            //Show Exception

           }
       }

  } else if(android.os.Build.VERSION.SDK_INT >= 11){
      try{
           Intent intent =new Intent();
           intent.setComponent(new ComponentName("com.android.contacts","com.android.contacts.vcard.ImportVCardActivity"));
           startActivity(intent);
      }catch(Exception e){
        //Show Exception

       }          
    }
 }