'Lord, remember unto David all his afflictions' (cp. 1 Chronicles 22:14), i.e. for good—to do him good in consequence: cp. Psalms 137:7. David] perhaps, here, 'the house of David,' or 'the representative of David.'
3-5. David's vow to find a permanent home for the ark: cp. 2 Samuel 7:2.