Both the Camera picture and All photos have same element locator then how can we click All pictures, i have explained everything in picture description
Appium interprets page as an XML, so there are no two elements with the same locator. So you can locate by the folder names for example.
def cameraPicturesLocatorBy = By.xpath("//*[@text='Camera pictures']")
and
def allPhotosLocatorBy = By.xpath("//*[@text='All photos']")