Here "the ways of Yahweh" refers to how Yahweh wants his people to act. This means David has done what Yahweh commands.