David kept the ways of Yahweh by keeping Yahweh's statutes instead of acting wickedly and turning from God.