This book is all about walking with God. To be undefiled in the way is to walk in the law of the Lord. If we understand that Old Testament laws have an application under the New Covenant, then we should also understand that Psalm 119:1 was written for us. The way we can be undefiled in the way is to walk in the law of the Lord.
Walking is an action. It requires effort to get somewhere. It is doing something. There is a teaching out there that proclaims: “One cannot overcome spiritual sin by doing physical things.” Yet, this is satanically deceptive because it clouds the clear picture of what God requires. God’s laws have a physical application, and they are to be used, to be kept, to be observed in our life experiences – interacting with other people and the rest of God’s creation. We have to observe or keep them; we have to “walk” in them, to become sanctified. Put another way, the character God is creating in us does not become ours unless His way is put into practice.