First, you are trying to make a telephone do the job of an actual camera. The problem you are having is called dynamic range. Our eyes can see extremes of brightness that a camera cannot, especially not something like a cell phone camera. Even with a proper camera, you have to understand and know what you are doing in order to have a bright background properly exposed AND have a darker foreground properly exposed. In the simplest terms, you read the exposure value for the bright background and set the camera manually to those parameters. You then use a strong flash to fill in the dark foreground.
As for having all areas in focus, that again is a matter of having a real camera that allows you to adjust aperture values to obtain the depth of field you want.
Frankly, using a phone to take photos really forces you to be nothing more than a snapshot taker, not a photographer.