A bicycle is a vehicle. Vehicles use the road.
Sidewalks are for pedestrians. It is illegal to ride on the sidewalk in some communities.
If a road is too narrow to safely share with cars, take the lane. That means ride near the middle or just to the right of the middle so cars must change lanes or cross the yellow line to pass.
Go
here for info about riding safely in traffic.