Multiple Select of Checkboxes in list view in Appium

My requirement includes selecting of checkboxes for all the items. Attributes avail which are index, resource-id are static. The instance is of dynamic & increases with the items list.
ref:: 0,1,2,3 et…

How to select the checkboxes of the list in appium??

WebElement checkboxallSelection = driver.findElementByXPath("//android.widget.paths[contains 
 (@instance, '0')]");
 checkboxallSelection.click();

The above sample code is for 1 selection of checkbox. But, i need for all 0,1,2,…n?
How can I attain this??

Selenium supports selecting multiple elements by one XPath statement… put an ‘s’ behind .findElement to get an array/list of WebElements… it would be .findElementsByXPath(…)… You can also do webElement.findElementsByXPath(…) if you want to first select the element that contains your whole list and then select the individual list items out in into an array… Once you have your list, you can iterate over it in a for loop

Thanks for the reply. I will try and let you know!

I have some idle time at work and reread your post… Your XPath is a little special and you may not be able to get it done with a list of elements… you could also try:

int i = 0;
while(true){
WebElement checkboxallSelection = driver.findElementByXPath(“//android.widget.paths[contains(@instance, “+i+”)]”);
if(checkboxallSelection == null){
break;
}
checkboxallSelection.click();
i++
}