Smart, safe, courteous, and legal vary by location. Downtown, you're likely to lose on all counts; in other words, you should be on the road. Around here, it is legal to ride on the sidewalk, but it is not always smart.
In some cases, it is safer (despite the stats, which lump many situations into one category) to be on the sidewalk. We have many gated neighborhoods here, where the driveways can be a half mile apart, the sidewalks are 6 feet wide (imagine passing a golfcart!), and the roads have no shoulders.
In contrast, in small city downtowns, where doors open onto 4 foot wide sidewalks full of pedestrians, you don't need to see the law to know it's not right to be on the sidewalk.
If you pick the spots where it makes sense to be on the sidewalk, you're very unlikely to get a ticket, no matter the letter of the law.
__________________
Campione Del Mondo Immaginario