public void removeGravityFromAccelerometerData(long bufferDuration)
    {
        List<Reading> buffer = new ArrayList<Reading>();
        boolean bufferFull = false;
        
        for (Reading reading: readingsAccelerometer)
        {
            if (buffer.size() > 0 && 
                    (reading.getTimestamp() - buffer.get(0).getTimestamp()) > bufferDuration)
            {
                bufferFull = true;
            }
            else
            {
                bufferFull = false;
                buffer.add(reading);
            }
            
            if (bufferFull)
            {
                float meanValueX = 0, meanValueY = 0, meanValueZ = 0;
                for (Reading readingB: buffer)
                {
                    meanValueX += readingB.getX();
                    meanValueY += readingB.getY();
                    meanValueZ += readingB.getZ();
                }
                
                meanValueX /= buffer.size(); meanValueY /= buffer.size();
                meanValueZ /= buffer.size();
                
                reading.setNoGravityValues(reading.getX() - meanValueX, 
                        reading.getY() - meanValueY, 
                        reading.getZ() - meanValueZ);
                
                buffer.remove(0);
                buffer.add(reading);
            }
        }
    }