Sure, the sidewalk is safer - for the person on the bike. Keep the bike in the bike lane or in the street. Cars parking (or driving) in the bike lane is bad, right? This is the same thing.
Don't ride on the sidewalk unless you're five years old.