When I first moved to India, I was recommended by a foreigner to "permanently carry a knife or an anti-aggression spray" (sic). Foreigners are indeed an easy target as they are in unknown territory but the same applies to any country!
India is relatively safe for foreigners. While they are reported cases of rape/killing of foreigners, the most common crimes against tourists include pickpocketing, passport theft and scams.
To be on the safe side, observe the following precautions:
-Protect your belongings
-Avoid being alone in the streets late at night (especially if you are a woman)
-Don't accept food or drink from strangers
-In doubt regarding the safety of an area, check with your embassy
Looking back, the excitement of being in such a different country might have made me careless if not slightly euphoric (e.g. arrival alone in unknown areas in the middle of the night, sharing food with complete strangers). Overall, I felt very safe during my stay in India and Mumbai is the only place were I felt real animosity towards foreigners. Having said that, our experience was probably affected by our trip timing as we visited the city during a large gathering of Shiv Sainiks (who threw stones at us on the streets!).