使用adb提供的命令, 能夠很是方便地從PC中將通信錄批量導入android模擬器中.android
首先要先準備好固定格式的vcf文件, 該文件即android中的通信錄存儲格式文件.shell
格式以下:ide
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
導入的命令以下:spa
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