Never keep food inside your tent. When choosing a location for your tent, make sure it isn't close to fruit trees or berry bushes. These attract bears. When hiking through bear country there are a few things to keep in mind. Make sure that you travel in a group.
Bears are less likely to attack groups of six or more.
Carry a can of bear pepper spray in case of an attack. While walking through areas that have wild fruits and berries growing make noise. Talking whistling singing etc. Most bears will run away if they hear you coming toward them, but if startled the bear may attack. If a bear has already started attacking you because you startled him, the best defense is either using pepper spray, or play dead until the bear leaves the area.