On that bitter journey of David when he had to flee Jerusalem after having been betrayed by his son and deserted by his people, he is even cursed by a distant relative of Saul’s named Shimei. David will not permit his men to punish Shimei: it may be that God is speaking and has turned from David because of his sins (16:1-13). David’s feelings at this time are expressed in Psalms 3 and 4.
11 And David said to Abishai and all his servants, “See how my son who came from my own body seeks my life. How much more now may this Benjamite? Let him alone, and let him curse; for so the Lord has ordered him. 12 It may be that the Lord will look on my affliction, and that the Lord will repay me with good for his cursing this day.”
–> David’s humility was tested when he was insulted by a common man. He passed the test — humbles himself to God, not to Shimei. David won the battle over his pride.