David was staying in the stronghold at the time, and a Philistine detachment had occupied the town of Bethlehem.