How did God reveal himself to David?

According to tradition, it was never directly. It was invariably indirectly, such as through a prophet.