Counting number of contacts in Android Device

Has anyone already implemented counting total number of contacts in Android device?

You can do that by continuously scrolling in contacts. Whenever you scroll get all contacts visible on the screen by there id and store the text of it on a LinkedHashSet. add() method will return true or false, store that in a variable and make it terminating condition of the loop. After that get the size of HashSet.

Thanks for the advice. Do you have a sample code for this?

I don’t have the actual code, It’s just an idea, but here’s something i can give you for the time being.

            List<WebElement> elements = appiumDriver.findElementsById("ID of contact Name");
	LinkedHashSet<String> contactName = new LinkedHashSet<>();
	boolean flag = true;
	for (WebElement element : elements)
	{
		contactName.add(element.getText());
	}
	while (flag)
	{
		scroll(); //make a scroll with java script executor 
		elements.clear();
		elements = appiumDriver.findElementsById("ID of contact Name");

	
		for (WebElement element : elements)
		{
			flag = contactName.add(element.getText());
		}
	}
	contactName.size();