Understanding of David during his prayer in the cave. Solomon said in Proverbs 18:10, "The name of the Lord is a strong tower; the righteous run to it and are safe." When the righteous are in distress, they only focus on the Lord. The scripture also says in Psalm 34:2, "I will bless the Lord at all times; His praise shall continually be in my mouth."

When David fled from Absalom, he only sang to the Lord. Similarly, when he was in the wilderness of Judah, he only mentioned the Lord. In every trouble he faced, he trusted in the Lord. And when he was in the cave, he called only upon the Lord, as it says in Psalm 142:4, "I cry out to You, O Lord; I say, ‘You are my refuge, My portion in the land of the living.’"

What does it mean that David had "understanding"? When Saul and David were in the cave, David knew and saw that no one was standing with him in his wealth, wisdom, or strength. Therefore, his only recourse was to pray. David understood and said that he had no good except for prayer. Therefore, it is said, "Understanding of David" (in reference to Psalm 142) and so on....