The LORD rewarded me [David] according to my righteousness: according to the cleanness of my hands hath he recompensed me. 2 Samuel:22:21He kept God's statutes and commandments.
Therefore the LORD hath recompensed me according to my righteousness; according to my cleanness in his eye sight. 2 Samuel 22:25
And if thou wilt walk in my ways, to keep my statutes and my commandments, as thy father David did walk, then I will lengthen thy days. [God talking to Solomon in a dream] 1 Kings 3:14He was upright, did everything God asked him to do, keeping all of God's statutes and judgments.
And if thou wilt walk before me, as David thy father walked, in integrity of heart, and in uprightness, to do according to all that I have commanded thee, and wilt keep my statutes and my judgments. 1 Kings 9:4He kept God's commandmnets, followed God, and always did what was right in God's eyes.
Thou hast not been as my servant David, who kept my commandments, and who followed me with all his heart, to do that only which was right in mine eyes. 1 Kings 14:8
David did that which was right in the eyes of the Lord, and turned not aside from anything that he commanded him all the days of his life, save only in the matter of Uriah the Hittite. 1 Kings 15:5
And David's heart smote him after that he had numbered the people. And David said unto the Lord, I have sinned greatly in that I have done. 2 Samuel 24:10, 1 Chronicles 21:8