Why is my phone randomly shutting down? (And other problems)
So I've had my HTC one m9 for about two years, (I got it used) and I've been experiencing lots of problems within the last year. When I first got it, it was working fine, but now it's really getting on my nerves. My main problem is that it shuts down seemingly at random times. Usually because of these factors:
When it shuts down, it (sometimes) wipes the app data and says that I have to update everything when my storage used stays the same. This happening several times results in my phone filling up with duplicate updates. But it doesn't wipe it every time.
It also has been consistently powering off below 40%, like I said, and when I put it on a charger, it says it's at anywhere from 5-20%.
Also sometimes when I power it on (not after a random shutdown) it will reset only my keyboard settings and quick settings.
I've tried wiping the cache partition and factory resetting it multiple times. Any help would be much appreciated.
Running Android marshmallow if that helps.