Living in Colorado with lots of Black Bears we hear stories all the time of people who have bears rip off their front doors, go through a window or take the garage door off the runners just to get into a house. If a bear wants in ... he gets in.
An electric fence could possibly deter a bear if he wasn't too hungry. They've even gone through electric fences out here to get to livestock so that's not 100% safe either.
The best thing is to not leave garbage or food (dog food, cat food, bird feeders, etc.) outside - ever as that may draw them to your place.