I hope you don't mind a comment from a woman on this subject. A foreskin that's difficult to retract and painful, may well be a condition called phimosis[sp?]
It's possibly caused by high blood glucose. If the BG is high enough [around 10 in most people] glucose will escape through the kidneys into the urine. [ that's why urine testing for glucose isn't a very good way of monitoring for glucose control. If you have glucose in your urine, your blood glucose level is already too high]
Pretty much the only things you can do yourself is a] better personal hygiene [not that I'm saying yours isn't good, but it may not be enough
and b] get the blood sugar down below the renal threshold, so it doesn't escape into the urine.
I would advise seeing the doctor about it. If t goes on the only treatment may be circumcision. You can buy clinistix quite cheaply from a pharmacy and check if you have any glucose in your urine.
Hana