The X axis is horizontal and points to the right, the Y axis is vertical and points up, and the Z axis is directed to the outside of the front surface of the screen. In this system, the coordinates behind the screen have negative Z values.
The reference coordinate system is defined as a direct orthonormal basis, where:
X is defined as the vector product YZ (It is tangential to the ground at the device current location and roughly points East). Y is tangential to the ground at the device current location and points towards magnetic north. Z points towards the sky and is perpendicular to the ground.
In your case, try this,
if(Round(y,4) < 8.0){ Log.d("sensor", "=====UP===="); } else if(Round(y,4) < -8.0){ Log.d("sensor", "=====DOWN===="); }

source share