Spyware is usually specific to the device it is installed on. So, if you get a new phone, the spyware will not transfer to the new device. However, if you backup your old phone before getting a new one, the spyware could also be backed up. This is why it's essential to only backup your data to a trusted source.