2 Samuel 22:23

For all his judgments were before me: and as for his statutes, I did not depart from them.

This verse belongs to a song David composed while Saul was pursuing him to take his life. The song recounts his dangers and deliverances and praises God for preserving him. It gives praise to God as his preserver.

It means David kept God's judgments continually in view and did not turn aside from God's statutes. The song reflects his trust in God and his integrity and purity of heart during the earlier part of his life. It expresses his devotion and trust in God during severe trials. His obedience to God's law was part of the righteousness and integrity for which he says God rewarded him.