Preventive measures for prostatitis include maintaining good hygiene, practicing safe sex, and avoiding activities that can irritate the prostate, such as prolonged sitting or cycling. Regular medical check-ups can also help in early detection and management.