Choose a route that is frequented by other pedestrians, bikers, etc. There is safety in numbers.
Be aware of your surroundings. It’s best not to be distracted by your phone or wear earphones. Being aware and alert helps you avoid being a target.
If there are no sidewalks, walk facing traffic and in a single file line.
Check out these 11 Rules for Staying Safe While Walking.