Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android adb command to get total contacts on device

Tags:

android

adb

Can you please let me know if there is any adb command that can be used to find total number of contacts on device. -thanks in advance, Manju

like image 512
Manju Avatar asked Sep 19 '14 06:09

Manju


2 Answers

this does not require root and sqlite:

adb shell content query --uri content://contacts/phones/  --projection display_name:number:notes  # google contacts?

adb shell content query --uri content://com.android.contacts/data --projection display_name:data1:data4:contact_id
like image 99
eadmaster Avatar answered Oct 24 '22 01:10

eadmaster


There are a few adb commands that appear to work (as of on Android 10).

List the people in the contact list

adb shell content query --uri content://contacts/people/

Count people in contact list

Assuming you have a bash shell (Linux, OSX, or Windows Subsystem for Linux), you can pipe the output of those commands to wc -l to get the count.

adb shell content query --uri content://contacts/people/ | wc -l

Other interesting commands include:

List the phone numbers

adb shell content query --uri content://contacts/phones/

List the groups

adb shell content query --uri content://contacts/groups/

List group membership

adb shell content query --uri content://contacts/groupmembership/

List organizations

adb shell content query --uri content://contacts/organizations/
like image 24
TimeMalt Avatar answered Oct 24 '22 00:10

TimeMalt