It means that David, unlike Saul, wanted to do what God desired instead of what he wanted.
Saul was preparing to battle the Philistines, and he was instructed to wait seven days for Samuel to arrive and offer a sacrifice. When Samuel was late, Saul took it upon himself to offer the sacrifices--which he was not authorized to do. When Samuel did arrive, Saul admitted to the lesser sin of not waiting, but not the greater sin of usurping the duties of the priests.
Hence Samuel said Saul had acted foolishly, and that his dynasty would not last, as God would put a new man on the throne, one after God's heart instead of his own.
By contrast, David wanted to obey God. He wasn't perfect, but he was penitent.