How to Maintain Bone Density As You Age
On this topic, the science is clear. The first half of the answer is diet.  

Foods rich in calcium and vitamin D are a good start. It's also good to avoid additives like phosphoric acid (found in many sodas), which eat away at your bones. 

For the second half of the answer, there's exercise. As studies have shown, heavy compound exercises such as squats and deadlifts are ideal for maintaining bone density.  

And here's why:
The Impact of G-Forces on Bone Density
As studies have shown, exposing your body to G forces (high or low) has a dramatic effect on bone density.

At rest, your body experiences 1G of weight, which is the normal force of gravity on Earth.  

Astronauts in outer space who float around all day at 0G, experience dramatic losses in bone density in just a few short days.

Exercises such as squats and deadlifts on the other hand, expose you to anywhere from 2-3G depending on your strength.  

Skateboarders landing jumps can experience as much as 10-20G depending on the height.
Why Sprinting is the Best Way to Ramp Up 
Your G Forces
To get the optimal benefit from G-force exposure, there's an ideal combination of force, duration, and frequency.  

Another way to increase this (but only for a short time) is through impact. For example, when you jump and land back on the ground, your body temporarily experiences a G force anywhere from 2-5G for a fraction of a second.  

As studies have shown, sprinting actually increases your bone density in the short term, and helps you maintain it as you age, in the long term.