Search code examples
androidadbandroid-debugandroid-debugging

How to store contacts from adb shell? [Android]


I came across the following: Android adb command to get total contacts on device

Im at a point where my display isnt working. The command given above just displays my contatcts. Is there some way I can convert it to a backup file? So that I can restore it on my spare android phone?


Solution

  • I'm not sure whether creating a backup file manually is possible (you would need to know how data is stored and read by the contacts app in .vcf files), but if you simply want to extract and save the data:

    Simply use ">" sign, eg.:

    adb shell content query --uri content://com.android.contacts/contacts | wc -l > Contacts.txt
    

    or (if you want to specify a path)

    adb shell content query --uri content://com.android.contacts/contacts | wc -l > /home/pi/Desktop/Contacts.txt
    

    This will create a file named Contacts (with a .txt format) that holds the command output