One weird trick: try not to appear American. American tourists are targeted because they tend to have valuables, also many cultures have a low opinion of the USA (anyone from the USA deserves behaviour X in response). I wish it weren’t like that, but it is hard to change stereotypes.
When travelling I might make out I am a hippy traveller type (low value target), or act like I’m from another country (e.g. Spanish tourists are known to be tight/tacaño in Morocco), and I try to avoid carrying or wearing anything that makes me stand out as a target (bumbag, camera, expensive accessories, high value branded clothes).
As a broad rule, you need to be most safety conscious in high density tourist areas. The only places I have been where I really knew I was unsafe were Rio (dangerous to locals too), and Nha Trang. In areas with very few tourists, I have usually been able to be fairly trusting, which leads to better experiences. Travelling as a hypersensitive victim is not fun: people sense your distrust and react poorly to it.
I am a New Zealander, and we tend to have a reputation for friendliness, which I try to project and maintain our reputation.
I have been obnoxiously drunk a few times when I have pretended to be Australian or American, sorry guys.