Apple devices are intended to be synced to a single library in an attempt to limit casual piracy. iTunes spots when you connect a device to a new library and offers, somewhat unhelpfully, to wipe the device and put whatever content is in the current library onto it even though it now remains the last repository of your data. Had you backed up your library you would not be in this position...
However, you should be able to:
- Backup the device to the new installation
- Transfer your purchases into a newly authorized library
- Recover any other media using third party tools as suggested in this post from forum regular Zevoneer
- Restore the device from the backup
This process should switch the association of the device to the new library, preserving the data and settings in your apps.
May also be prudent to attempt a backup to iCloud directly from the device before you start... Settings > iCloud > Storage & Backup > iCloud Backup > On. It won't save any media but it would preserve the general account settings and documents in case anything goes wrong while you are trying to extract your other data.
When you get it all fixed, make a backup!
tt2