code: public void attachIoDevice(IoDevice ioDevice) throws IOException {
          if (!isEnabled()) {
              throw new IllegalStateException("Cursor not enabled");
          }
          IoDevice oldDevice = getIoDevice();
          if (oldDevice != null && oldDevice.equals(ioDevice)) {
              Log.d(TAG, "Current and desired Io device are same");
              return;
          }
  
          if (!isIoDeviceCompatible(ioDevice)) {
              throw new IllegalArgumentException("IO device not compatible");
          }
          IoDevice availableIoDevice = mCursorManager.getAvailableIoDevice(ioDevice);
          if (availableIoDevice == null) {
              throw new IOException("IO device cannot be attached");
          }
  
          Log.d(TAG, "Attaching ioDevice:" + availableIoDevice.getDeviceId() + " to cursor:"
                     + mCursorID);
  
          mCursorManager.removeCursorFromScene(this);
          setIoDevice(availableIoDevice);
          mCursorManager.addCursorToScene(this);
          if (oldDevice != null)
          {
              resetIoDevice(oldDevice);
          }
      }
docs: Use this method to attach an available {@link IoDevice} to the {@link Cursor}. The
  currently attached {@link IoDevice} is released and a new {@link IoDevice} is attached to
  the {@link Cursor}.
  
  @param ioDevice the IoDevice to attach, this {@link IoDevice} should be one of the objects
  returned by {@link Cursor#getAvailableIoDevices()}
  @throws IOException The call return an {@link IOException} if this {@link IoDevice} cannot be
  attached.