Background
I\'ve had problems for quite a while now with players cheating in my android game. For a strict single-player game this wouldn\'t be a big is
Calculate your stats dynamically from a stored value.
private double getSaltedSqrt(int i){
return Math.sqrt(i)+1337;
}
private int getTrueValue(double i){
return (i-1337)*(i-1337);
}
This way, no regular-brained human will be able to find your values from RAM ever. Somebody with 100 health will have a health value of 1347.0
If somebody deals 10 damage to that player, you just have to call:
currentHealth = getSaltedSqrt(getTrueValue(currentHealth)-damage);
However, the most secure way to do this, is to implement all those changes via server.