Exercise correlates with a reduced risk of suffering dementia in later life, just as excess visceral fat is correlated with an increased risk of later developing dementia. The underlying mechanisms are somewhat different, but they both boil down to the quality of the blood vessels in your brain. Impaired blood vessels mean a lower blood flow or the breakages and lesions of vascular dementia - neither of which is good for you in the long term.
Another issue to consider in this context is the ongoing impact of atherosclerosis, the build-up of fatty material on blood vessel walls. This can result in sudden death due to blockage and rupture of larger deposits, but the condition harms your brain across the years leading up to that point:
We examined the relationship between systemic atherosclerosis, Alzheimer type pathology, and dementia in autopsies from 200 participants in the Baltimore Longitudinal Study of Aging, a prospective study of the effect of aging on cognition, 175 of whom had complete body autopsies. ... we found that the presence of intracranial but not coronary or aortic atherosclerosis significantly increased the odds of dementia.
Just as for the other forms of damage to blood vessels in the brain mentioned above, atherosclerosis is largely something that you do to yourself as a result of your lifestyle. Being fat and sedentary will get you there. Unfortunately, the characteristic mitochondrial damage of aging also spurs the onset of atherosclerosis - so a solution will be required one way or another even for those folk in perfect health. But the time left before you will be in pressing need of that solution is up to you, which is at least something.
Repairing mitochondrial damage is one of the long term solutions. Thirty-year-olds don't have atherosclerosis, so a comprehensive repair of your mitochondria is something that would only have to be done every few decades. For those people already suffering the build-up of material in their blood-vessels, forms of immune therapy or biomedical remediation are promising lines of research - the search for methods to safely break down unwanted chemicals and aggregates that build up with age.
The availability of these foreseeable forms of therapy still lies in the near future, however. In the here and now, the smart thing to do is take care of your health, rather than burning your candle at both ends while hoping that medical science progresses rapidly enough to save you from yourself.
Dolan H, Crain B, Troncoso J, Resnick SM, Zonderman AB, & Obrien RJ (2010). Atherosclerosis, dementia, and Alzheimer disease in the Baltimore Longitudinal Study of aging cohort. Annals of neurology, 68 (2), 231-40 PMID: 20695015