This will help with dirty water, but not contaminated water. Don't use water if:
One way to test water for possible contamination is to boil it and see if any residue remains.
Filtering
Pour it through some close-woven fabric several times, or construct a simple filter using layers of grass, sand, charcoal and rocks.
DIY water filter
Purifying
Boil it for ten minutes.