“King David said. ‘My son Solomon is young and inexperienced. The house that is to be built for Yahweh must be exceedingly magnificent, famous, and glorified throughout all lands. I will therefore make preparation for it.’ Thus King David provided materials in great quantity before his death.”
Based on 1 Kings, chapters 1-3, King David made a last minute decision about who was to succeed him. Of course, it was Solomon, but that was not clear until Solomon actually became the king. In fairness, Solomon was king while David was still old and alive. He wanted to provide the materials for King Solomon.