Most smartphones and tablets today have non-removable batteries. If a failing battery is still under warranty, it may be taken to the dealer where it was purchased for replacement. After warranty, people generally take their devices to a repair shop. However, there are retail outlets and websites that sell batteries and parts.
Do It Yourself
iPhone cases are generally held together with tiny five-pointed screws that require a special "pentalobe" screwdriver. Depending on the model, small cover plates may have to be loosened inside by removing tiny Phillips screws. iPhone kits are available with the appropriate tools.
The back covers on many Android phones attach by an adhesive. When the cover is pried off to replace the battery, it is often less sticky when pressed back on, and there are replacement adhesive strips molded to the contour of the phone. The back cover may also be damaged when removed, and replacement covers are also available.
If a gas builds up inside a faulty lithium ion battery, it can swell enough to cause the case to split apart. Although some advise making a pin hole in the battery to relieve the gas, the best solution is a new battery, because the gas will likely build up again.
Replacing the Battery Can Be Tricky
Depending on the device, battery replacement may be relatively easy, or it may require proper tools and manual dexterity as in this Galaxy S9 phone example. In addition, attaching the tiny battery plug (bottom right) to the phone's socket (bottom left) is tedious. The black vertical stripes are the 1/16" marks on the ruler.