You did the right thing. Also check the laws where you live re biking on the sidewalk. In some places its perfectly legal, especially in situations like these. Even if it isn't I have a hard time seeing you getting a ticket.
I'm a bike commuter, and I try to strike a balance between my rights, my convenience and courtesy to drivers, with of course my safety being the #1 priority. I'm on bike trails or the street most of the time. On some bridges I'll pop up to the sidewalk, and walk my bike if there's heavy foot traffic. I try to avoid major arterials both to not slow down car traffic and to reduce my stress level. Some bikers are pretty adamant about exercising their right to be anywhere a car is, but I feel if there's an option (like a neighborhood street) that's roughly equivalent for me and would be a net gain for everyone I'll take it. There's a bike path 100 feet from a busy road in my neighborhood and sometimes I'll see bikers bottling up traffic when they could easily (and more safely) do otherwise. At the same time, if you need to be in the road and won't be safe if cars try to pass you then by all means get out in the lane and protect yourself. Good luck and stay safe!