First, the basics. You are not in as much danger as you probably think you are. I've heard inexperienced travelers tell me a lot of ridiculous horror stories of shooting, kidnappings, and random killings of tourists. This is very unlikely to happen to you in the vast majority of places you will visit. The places where it does happen are the ones that are very hard to travel to, and where you probably don't want to be right now anyway. Like Baghdad or Mogadishu. I can guarantee you that if you come to Beijing, you are not going to be stuffed into an unmarked car by people looking to harvest your organs. I hope you're laughing, but somebody I talked to was seriously concerned about this possibility.
What you are in danger of are scams (which I'll cover in another post) and theft. Possibly via mugging, depending on the area. Also, women, I hate to say it, but you are more likely to be targeted, not just for theft, but for unwanted sexual attention. However, in most places you are not in any greater danger than you would be in your home city. So don't panic.
The places where you are in the most danger are in very very packed crowds (as in you are literally squeezing through people) and at night. Since you're probably going to be traveling through more nights than crowds, I'm going to focus on how to keep safe at night.
The basics, you probably already know:
-Walking alone is not ideal. Walking drunk is not ideal. Walking alone and drunk is just dumb. Don't do it.
-Act like you know where you are going, even if you don't
-Be aware of your surroundings- don't look at the ground all the time or talk on your cell phone
-Look relaxed but alert-- panicky people look like they're good targets because they probably don't know the area, and might be carrying valuables.
-Don't access an ATM at night. It makes it obvious that you're carrying cash when you walk away.
-Stick to well-lit areas with some people walking around, and give generous distance to dark, shadowy hiding places
-Don't pull out or show anything of great value (i.e. cameras, jewelry, money belts, or iPods)
-If you are confronted and told to hand over your valuables, don't argue or act like a hero, hand it over.
Now, here are a few slightly less well known ideas I liked to use to stay safe.
If you don't know where you are and don't know how to make it look like you know where you are, pick a random point a couple blocks distant, and walk to it, purposefully. Once you get to it, choose another and do the same thing. Keep doing this until you find a well-lit populated place of business where you can pull out a map or get directions without problems.
Plan ahead of time when you're going to need a map. If you have to pull out a map, make sure it's folded down to the part you need so that you can pull it out and have it in one hand without unfolding. Basically, make it look like it's something other than a map. Ideally, you'll have already done this before walking out into the street.
Use reflections. Shop windows, car mirrors, and anything glass are all your friends, because they can give you a view of what's going on behind you, without you twisting and turning. If you still have sunglasses on your person, you can pretend to inspect the lenses-- the curved lens is a great way to see what's behind you.
If you suspect that someone is following you, walk all the way around a city block until you're going the same direction you were originally. If they're still behind you, they are following you. Step inside a shop, hotel lobby, or any open, lit building with someone working inside, and tell the person that you are being followed.
If you keep a wallet in your pocket, keep it in the front pocket. If you must keep it in the back, tie a couple rubber bands around it so that you can more easily feel if someone tries to slip it out.
If you are in a place where mugging is reported to be common, carry a second wallet with a small amount of cash and some expired cards inside it. If you are mugged, throw this wallet to the ground and run, if you can.
Finally, use the city around you. The vast majority of people wherever you are is trustworthy and hates thieves and criminals more than they could ever hate you, regardless of your demographic. The vast majority of the city is your friend, and criminals are running scared of being caught by your friend. This is something that will help you stay calm if you're caught in a situation that feels unsafe.
I hope that helps. Safe travels!