I am saving data from Accelerometer Sensor to Database, but I want to do it in a separate thread. I tried to search it on Internet but most of them uses the same thread.
First you need to use registerListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler) and supply a Handler that is running on a background thread.
Create a HandlerThread, get its Looper, create a Handler supplying the looper.
This will let you receive the callbacks on the background thread. When finished ensure you remove the listener and then call Looper.quit(), to exit the thread.