You might be faced with this situation at times when you have a  jailbroken iPhone/iPod Touch. You might have played around with some  CYDIA apps, most notably the apps which try to modify the contents of  iTunes Database File. One of those apps is MewSeek which lets you add  the songs to the iTunes  library directly from your iPhone/iPod Touch.  Well sometimes it corrupts  the following two files iTunesDB and iTunesCDB.
You will get the following message on iTunes “Itunes cannot  read the contents of the iphone. Go to the summary tab in  IPhone  preferences and click restore to restore this iphone to factory   settings”.
If you didn’t Jailbreak and you are in this situation, you have no  choice but to do a full system restore on your iDevice and rely on a  backup. But if you have jailbroken your iDevice, you can use iPhoneBrowser or iFunBox  to explore the contents and fix it yourself without doing a restore.  You might have to copy your songs/ringtones/videos back again but you  still have everything else. The Songs etc are there on the device its  just that the DB files are corrupted. So using iPhoneBrowser or iFunBox navigate to the following directory
 /var/mobile/Media/iTunes_Control
Now within the above directory you will find two more directories
 Music
 Under Music, delete the following directory -  itunes_db_checked
 iTunes
 Under iTunes, delete the following two files - iTunesDB and iTunesCDB
Disconnect the iDevice and reconnect. iTunes will detect it fine and  you may or may not have your media. Try the option below which might  help with just reusing the backed up DB files. You can also use iPhoneBackupExtractor to get the same DB files and see if they help.
 FYI - You may try copying the iTunesDB and iTunesCDB from tmp folder back to iTunes directory to see if your songs/ringtones/videos come back
 This is all you need to get your iDevice back in shape without a restore.