Shanghai is generally pretty safe, however pay attention to the following:
traffic: obey the traffic light, don't follow the local's bad example. that being said, many locals don't follow the rules, especially if they are on scooter
crowds: you need to be cautious if you catch yourself in Shanghai during festival periods, or anywhere that may be crowded. people are quite aggressive and will push around. Some death accidents happened in the past due to over-crowding. This also applied in the metro during rush hour.
pickpockets: pickpockets are a lot less common now compared to before, the city is really cracking it down. However still be careful especially whenever you go to tourists spots like Yu Garden, The Bund, or in a crowded Metro.
alcohol: many clubs and bars serve fake alcohol in Shanghai, better to avoid getting alcoholic drinks especially cocktails. if you must drink, buy your own alcohol from a supermarket or convenience shop.
One last thing, no one will rob or stab you, but definitely don't get into fights with the locals/Chinese especially if you've had some drinks or if the counterparts did, lately the foreigners in Shanghai are getting bad rep so some locals feel a bit hostile towards rude visitors, especially guys.