St Petersburg made a name for itself in the nineties as the crime capital of Russia, although how much this was true and how much the reputation relied on discrediting journalism and gangster films is a debatable point. Either way, that type of organized crime never had any effect on tourists.
As in all large cities, petty crime can be a problem and tourists are often the target - for the obvious reasons that they stand out in a crowd and are more likely to be carrying large amounts of cash or valuables. Pickpockets of various species are the main threat, and they tend to be most prevalent on public transport, especially on the metro in the center, and round tourist traps. To avoid being a victim, follow the obvious precautions: do not carry more cash than necessary and try not to display large sums in public places, keep large sums in a money belt or sealable inner pocket, keep credit cards separately, and don't carry valuables in a backpack or easily opened bag. Recent police efforts seem to have cut the number of incidents considerably, but it's still worth being careful.
Violent crime of any sort is extremely unlikely to be a problem for tourists. Mugging is rare in St Petersburg and you are only likely to encounter this late at night if you are doing something to be ashamed of or are on your own a long way from the center. There are not really any 'no-go' areas of St Petersburg, or certainly none that a visitor is likely to wander into by mistake, but there is a constant low-level threat of drunken aggression from xenophobic thugs, so you are advised not to act too loudly or brashly in bars and clubs, and to be polite but firm with anyone who approaches you in the street and tries to strike up conversation.
This is particularly true for anyone who is dark-skinned, as St Petersburg has a small but high-profile skin-head population. Again, it is only really dangerous to be out late away from the center.
If you are robbed while in St Petersburg, then for insurance purposes you will need to obtain a police report (the same goes if you lose anything valuable). This will be easier with the help of a Russian or Russian-speaker, but can be done on your own (first call the English-language police line on +7 (812) 164 9787).
Finally, the Russian Police have a terrible reputation for corruption and abuse of authority. Again, this is very unlikely to be an issue in St. Petersburg (except if you are driving), where the police have not been known to target foreigners as they once did in Moscow. It's worth being careful if you travel outside the city, however, and it's also worth being aware of a few points of Russian legislation.
The police need little pretext to ask to inspect your documents although, as mentioned above, they rarely target foreigners (again, unfortunately, dark-skinned travelers are more likely to have problems). If you are stopped, a foreign passport is normally enough to pacify them, and you are not legally obliged to carry identification. In practice, it's easier to carry photocopies of your documents just in case.
Rules for the sale of alcohol have changed regularly over the last few years, and it is likely that soon it will be impossible to buy any type of alcohol in shops after 11pm (as is already the case for wines and spirits). Drinking low-alcohol drinks (beer) in the street is not technically illegal, although it is illegal in "public places", which include several parks and areas near railway stations, schools, and major monuments. It is also illegal to be drunk in public, and if you are severely intoxicated (unable to stand, or causing a disturbance), the police have grounds to take you into custody until you have sobered up.
Jaywalking is illegal in Russia, and you can only cross the street at designated pedestrian crossings (be aware that not all drivers can be relied on to stop, however). It has been know for the traffic police to stop jaywalkers and issue them with small fines to be paid via local banks, which they are entirely within their right to do.