Verse 21 already said that he will be rewarded for his virtue!
Rashi (27): This refers to when David could have killed Sha'ul in the cave, and did not.
Malbim (Tehilim 18:25): Here he says that his virtue is in front of Hashem's eyes; He knows the roots [in David's soul] from where the actions came, and He will reward him accordingly.
How did Hashem reward David for his virtue?
Mahari Kara: The second time David passed up an opportunity to kill Sha'ul, he said "Hashem should return the Tzedakah" (Shmuel I, 26:23); Malbim (26:23) - one who does Tzedakah should have an opportunity to do it again, just like David received another opportunity to kill him, and refrained 1 .
Radak (Tehilim 18:25): Sha'ul, his household and his kingship were finished off, and I endured and my kingship endures.
Shmuel I, 24:19: [The first time he refrained, Sha'ul said] "Hashem should pay good to you in place of today, that you did to me." Here is past tense; David points out that Hashem fulfilled this. (PF)