The best way to thwart food-raiding bears is to use bearproof food lockers, provided in state and national parks. Of course, bag all litter and fish waste and keep it in the locker as well. Do not keep your food in your vehicle.
Bears routinely break in, often breaking out windows, when food is left inside.
In national forests or wilderness, where no such lockers are provided, the best answer is making a bearproof food hang, that is, suspending all of your food double wrapped in one or two heavy duty plastic garbage bags. Using a bearproof food canister is considered a must above tree line, particularly in Yosemite and Kings Canyon national parks. Food hangs can be accomplished two ways, with your food in a single bag, or by counterbalancing two bags. This is accomplished by tying a rock to a rope, then throwing it over a high but sturdy tree limb. Next tie your food bag to the rope and hoist it in the air.