David was in the stronghold at the time, while a Philistine garrison was in Bethlehem.