Sexually transmitted infections, or STIs, can cause hematuria. Safe sex practices, such as using a condom, may help prevent STIs.