Theoretically, yes, a phone or tablet could work just as well in say the International Space Station (ISS) as it does here on the ground.
LetsLet's break this down a bit.
There are two types of motion a device needs to detect.
Linear Motion
Self contained-contained accelerometers use the deviation of a spring coupled-coupled mass from a normal rest point as a measure of acceleration force in that axis. Obviously you need three of these to detect motion in any axis.
Knowing, and tracking those forces you can "dead-reckon" the speed and direction of travel of the device from it'sits original "power-on" location. Factor in an accurate clock, and you can also figure the current position.
That sounds simple, but the math is actually quite complex and errors in the system cause a drift over time.
Rotation
Rotation is obviously spin about any axis.
Spin Sensors
Rotation can be measured using a gyroscope or a spin sensor. TheseThese devices again have a loosely coupled mass that is free to rotate, or is driven, in a particular axis. When the body of your device rotates, the difference between rotations tells you how much the device is rotating.
Spin sensors and gyroscopes don't care about gravity, other that perhaps some frictional differences.
Gravity Referenced Accelerometer Rotation
Since accelerometers measure the force acting on a loosely suspended mass, when that sensor is vertical relative to the earth, there will of course be a deflection in the spring due to the weight of the mass due to gravity. This offset is mathematically removed by the software in order to extract the acceleration part.
However, since the three axis accelerometers will produce different offsets depending on their orientation, it is possible to mathematically detect spin from the difference in the offsets.
However, though this method works, it is subject to variances in G. It would not work in space. It would also be significantly less functional in a maneuvering aircraft. Even a car going round a tight bend at speed could be problematic.
Accelerometer Spin Detection
It is possible, with two sets of sufficiently sensitive accelerometers, to detect spin from the difference in acceleration between accelerometers.
Since each accelerometer has to move relative to the other, there will be a difference in acceleration in that axis between each. Those values can again be used mathematically to predict the spin.
Simply put, if you can tell from the accelerometers centered at one end of the phone that the centre point has moved to \$X_1,Y_1, Z_1\$, and the other end is now at \$X_2,Y_2, Z_2\$, calculating the three angles is trivial.
This method is NOT affected by gravity.
Will YOUR Phone or Tablet Work On The ISS
As you can see from the above it really depends on which methods your device uses.
Technically it could be built, and programmed, to do so. You may need to shut it down and power it up again to recalibrate it, but with the right systems in place it should work fine. At least for playing that "aircraft simulation game".
Drift may be a larger issue on the ISS though. Since phones in normal G have the ability to known which way "down" is at that particular moment, they can re-adjust over time. A space based-based unit would need an occasional manual reset to indicate the "normal" direction.