David said this by the priest, for he was to make the inquiry of God, Numbers 27:21, and David puts the words into his mouth.
Related Commentaries of 1 Samuel 23:10
1 Samuel 23:10
10 Then said David, O LORD God of Israel, thy servant hath certainly heard that Saul seeketh to come to Keilah, to destroy the city for my sake.