David has recorded in this psalm the prayers which he offered up to God when he heard of his having been betrayed by the Ziphites, and was reduced to a situation of extreme danger. It cannot fail to impress us with a high idea of his indomitable faith, thus to find him calling upon the name of God in the immediate prospect of death.
To the chief musician on Neginoth. A Psalm of David for instruction: when the Ziphites came and said to Saul, Doth not David hide himself with us?
We know from the sacred history that David frequently concealed himself in that part of the wilderness which adjoined to the Ziphites. It appears (1 Samuel 23:19; 26:1) that he was betrayed by them on two different occasions; and he takes notice of the particular circumstances in which the psalm was written, to teach us that we should never despair of divine help even in the worst situation. Surrounded as he was by hostile troops, and hemmed in on every side by apparently inevitable destruction, we cannot but admire the rare and heroical intrepidity which he displayed in committing himself, by prayer, to the Almighty. It might have appeared just as credible that God could bring the dead out of the grave, as that he could preserve him in such circumstances; for it seemed impossible that he should escape from the cave where he was concealed with his life.