David was called a man after God's own heart. David's longing was always to be close to God. David spent many years on the run, living in caves, hiding out among the enemies of Israel. During this time, he poured out his heart in prayers and song, longing to be near to God, depending on God for his strength. God forged his character not only on the battlefield, but in the caves of the wilderness when he was on the run from Saul.
When Saul was defeated by the Philistines on Mount Gilboa, things turned around for David. One by one, his enemies were neutralized. In a few years, David found himself King of Israel as God had promised. No longer did he have to live in caves in fear of his life from his own countrymen. He captured the stronghold of the Jebusites and made this his city, the City of David. The king of Tyre sent materials and craftsmen to build a palace for David. Then "David realized that Yahweh had established his a king of Israel..." (2 Sam 5:12). David's life took a definite turn for the better.
Take a look at the song written for the dedication of the house in the 30th Psalm. Some of the things he writes are, "I will extol You O Lord, for You have lifted me up (v1), O Lord, by your favor you have made my mountain to stand strong (v7), (v11) You have turned my mourning into dancing." David attributes his peace to God who has shown his favor and strengthened him. But notice what else David says..."Now as for me, I said in my prosperity, I will never be moved" (v6). David loved the Lord. He did not forget him in his prosperity. In fact, David so longed for God, that his next project was to try and bring the Ark of the Covenant close to him in his city.
This is the kind of devotion God desires from us. He wants us to love him with all our hearts, soul, mind, and strength. He wants us to be a people after his own heart. He wants us to commune with him, to be like him, to love like him, to show kindness like him.
Hardships, persecution, famine, and things of these nature can be trying to our patience, and our faith. However, God often uses these sorts of things to forge our character and make us better. The greater challenge to our devotion is prosperity. Israel demonstrated this when they went into the land flowing with milk and honey and promptly forgot God as Moses had warned them they would. Like David, we need to say, "In my prosperity, I will not be moved." Indeed, prosperity can be a great blessing of stewardship.