Amidst enemies, David said he would hope continually and praise God. When David was in despair, He knew that he should put his hope in God and that he would praise again. Therefore, he did not lose heart during afflictions because he was looking toward things unseen. Paul had hope in God that there would be a resurrection of the dead. Jesus is our hope.
Earthly things are a vain hope for safety.
God watches over those who hope in His mercy. Those that hope in and wait on the Lord will renew their strength and not grow weary. We should wait for and hope in God rather than in earthly things. Therefore, he looked to the Lord and waited for the God of his salvation. This hope made his heart yearn within him.