Use the adb command to import address book contacts into the Android simulator

  • 2020-06-15 10:10:20
  • OfStack

This example demonstrates how to import address book contacts into the Android simulator using the adb command. Share to everybody for everybody reference. Specific implementation methods are as follows:

Using the command provided by adb, it is very easy to import the address book from PC into the android emulator.

First, prepare the fixed contacts.vcf file, which is the address book store file in android. The format is as follows:

BEGIN:VCARD  
VERSION:3.0 
N:15200000000;;;; 
TEL;TYPE=cell:15200000000 
END:VCARD 
BEGIN:VCARD 
VERSION:3.0 
N:15200000011;;;; 
TEL;TYPE=cell:15200000011 
END:VCARD

The import command is as follows:
#  First clear the original contact list   
adb -s emulator-5554 shell pm clear com.android.providers.contacts 
# Will the correct format of the address book file contacts.vcf, The import android In the simulator , And wait for the simulator to refresh for a few seconds  
adb -s emulator-5554 push contacts.vcf /sdcard/contacts.vcf 
sleep 3 
# From the file , The contact import to android In the simulator's address book , The duration of the import process depends on the number of contacts . 
adb -s emulator-5554 shell am start -t "text/x-vcard" -d "file:///sdcard/contacts.vcf" -a android.intent.action.VIEW com.android.contacts 
sleep 10

OK, if none of the above is a problem, then a new contact information is added to the simulator's address book.

I hope this article has been helpful for your Android programming.


Related articles: