I have a phone whose screen broke, but I'd like to export its contacts to .vcf
so I can import them to another phone. I usually do this with the built-in import/export function in the Contacts app overflow menu, but without a screen it is inaccessible. Is it possible to do this via adb?
-
1Does your phone support OTG? If so, you could plug in a mouse to control/click on the screen to do the backup, then either upload to a cloud location or boot to recovery, and use adb pull to pull the backup file off of the device to your computer.– DukeSilversJazzCommented Jun 5, 2017 at 15:33
-
2Similar question here: android.stackexchange.com/questions/25646/…– esQmo_Commented Jun 5, 2017 at 16:26
-
A root method: android.stackexchange.com/a/215426/218526– Irfan LatifCommented Jan 6, 2020 at 16:09
2 Answers
The contacts database can be queried using the ADB shell:
adb shell content query --uri content://com.android.contacts/data
The command will dump all the content of the database only if the shell
have the permission READ_CONTACTS
, else it will fail.
-
2
adb shell content query --uri content://com.android.contacts/data >> contacts.vcf
saves the contacts to a file (Linux). Commented Jul 1, 2022 at 9:26 -
1@user598527 While this does dump some data to a file, but it is not a valid .vcf and can't be imported by the contacts app. Also, vcf-validator from vcftools also says it is not valid too.– YosephCommented Aug 17, 2022 at 17:39
Yes and no. If your screen is working, you can use an OTG cable or a MicroUSB to USB adapter and plug a mouse into your phone. Works like a dream. If you have no visual display that is another matter.
- You must have already enabled USB debugging.
- You must have already connected the phone to your computer and verified it.
- You must have already rooted your phone to access the contacts file.
It's extremely difficult
If you have done the above then you send the adb pull
request to the correct location, and with that received file you will have to do a couple of things.
- Find out the correct format for your phone's contacts DB.
- Figure out the correct conversation script to convert to the new phone's DB format.
- Send the converted file to the new phone.
Easiest Solution
Just make sure your contacts are backed up and linked to your Gmail email.