使用adb命令向Android模拟器中批量导入通讯录联系人的方法:
使用adb提供的命令, 可以非常方便地从PC中将通讯录批量导入android模拟器中.
首先要先准备好固定格式的vcf文件, 该文件即android中的通讯录存储格式文件.
格式如下:
BEGIN:VCARD VERSION:2.1 N:;Qiqi;;; FN:Qiqi TEL;HOME:7474 EMAIL;HOME:qiqi.com ADR;HOME:;;Qiqi;;;; END:VCARD BEGIN:VCARD VERSION:2.1 N:;Re;;; FN:Re TEL;HOME:73 EMAIL;HOME:re.com ADR;HOME:;;Re;;;; END:VCARD BEGIN:VCARD VERSION:2.1 N:;Staill;;; FN:Staill TEL;HOME:782-455 EMAIL;HOME:staill.com ADR;HOME:;;Staill;;;; END:VCARD BEGIN:VCARD VERSION:2.1 N:;Tian;;; FN:Tian TEL;HOME:8426 EMAIL;HOME:tian.com ADR;HOME:;;Tian;;;; END:VCARD BEGIN:VCARD VERSION:2.1 N:;Uuu;;; FN:Uuu TEL;HOME:888 EMAIL;HOME:uuu.com ADR;HOME:;;Uuu;;;; END:VCARD BEGIN:VCARD VERSION:2.1 N:;Victory;;; FN:Victory TEL;HOME:842-8679 EMAIL;HOME:victory.com ADR;HOME:;;Victory;;;; END:VCARD
导入的命令如下:
1 // 清除原通讯录联系人 2 3 adb -s emulator-5554 shell pm clear com.android.providers.contacts 4 5 6 // 将正确格式的通讯录文件contacts.vcf, 导入android模拟器中, 并等待模拟器刷新几秒钟 7 8 adb -s emulator-5555 push contacts.vcf /sdcard/contacts.vcf 9 10 11 // 从文件中, 将联系人import到android模拟器的通讯录中, 导入过程耗时依联系人数量而定. 12 13 adb -s emulator-5554 shell am start -t "text/x-vcard" -d "file:///sdcard/contacts.vcf" -a android.intent.action.VIEW com.android.contacts