King Saul pursued David on several occasions, seeking to kill him. There were two different times that the Ziphites, relatives of David, sold him out. One of those was in 1 Samuel 23. The Ziphite spies told Saul where David was hiding and Saul went after him. He was about to find David when he got word that the Philistines had made a raid against the land. So Saul left David to go fight the Philistines: “So Saul returned from pursuing after David and went against the Philistines. Therefore that place was called Rock of Escape” 1 Samuel 23:28 ESV.
It was during this time of David being pursued that he wrote what is now Psalm 54. David knew full well that it was God who sustains him: “Behold, God is my helper; the Lord is the upholder of my life” (Psalm 54:4). It’s clear that David trusted God the entire time. David knew that, somehow, God would keep him safe from Saul. Saul was bent on finding, catching, and killing David. Yet God upheld him and kept him safe.
David wrote, “For he has delivered me from every trouble, and my eye has looked in triumph on my enemies” (vs. 7). God still delivers us from our troubles. He upholds us and helps deliver us from every trouble.