This psalm has some explanations. The superscription says, “A Contemplation of David when the Ziphites went and said to Saul, ‘Is David not hiding with us?’” We cannot pin down whether this refers 1 Samuel 23 or 26 because in two different occasions Ziphites informed Saul the location of David.
In 1 Sam. 23:13-29, David was in the Wilderness of Ziph, and Jonathan, Saul’s son, visited him and made a covenant (23:14-18). Ziphites gave the information and Saul came to catch David. However, Saul received word that the Philistines had invaded the land of Israel (23:19-28). Saul had to leave and David went to the strongholds of Ein Gedi (23:29).
1 Samuel 26, when Ziphites informed Saul that David was in the Wilderness of Ziph Saul came to catch him. However, when he camped on the Hill of Hachilah with his 3,000 men the Lord caused a deep sleep to fall on Saul and all his men (26:12). David had the opportunity to kill Saul there but saved his life because Saul was the Lord’s anointed.
It is just one more example!
God saved David’s life twice through two different means in the wilderness of Ziph. However, God saved David’s life numerous times in many occasions through many different ways. This psalm is in that sense a generic song for salvation. When we cry out to God, God hears and answers to our prayers:
“Save me, O God, by your name, and vindicate me by your might. Hear my prayer, O God; give ear to the words of my mouth. For the insolent have risen against me, the ruthless seek my life; they do not set God before them. Selah”
We know already the outcome because God has done that thousands of time!
Even in the most serious condition, God can save us. “But surely, God is my helper; the Lord is the upholder of my life. He will repay my enemies for their evil. In your faithfulness, put an end to them. With a freewill offering I will sacrifice to you; I will give thanks to your name, O Lord, for it is good.”
Before David experienced salvation, he already promised to give offering and sacrifice to God. God’s salvation was so sure to him because God had done that already thousands of times. It was a proven fact: “For he has delivered me from every trouble, and my eye has looked in triumph on my enemies.”