You always should be very careful where ever you go, unless you are pretty familiar with the area. Most of the time when we get out of our own country, we are definitely going to places we have never been. So, we always should be careful.
Same going to Rio de Janeiro...
Now consider, if you are lost in the Bronx (New York), at the wrong time or
wrong place, you can get hurt. But now, if you are not in the US, without the inherent protection of a 1st world country, the risks are magnified.
Take Brazil as an example! Unfortunately the majority of Brazilians live in poverty - that can bring added danger as those less fortunate stoop to crime to survive. The slums are growing bigger
everyday and crime increases. But also it does not mean that you can
not be safe and have a wonderful time there.
My advice is to know
someone there, that speaks Portuguese, the person that is familiar with
the area and will be able to tell you where to go. Don't call attention to the fact that you are a visitor. Observe the Brazilians and how they dress, casual and comfortable, and emulate them. Don't take your real jewelry, use costume jewelry that you would be willing to give up if confronted on the bus or someone on the street.