Given the context (see 2 Samuel 7:1–3), that this prayer of David follows the words of the Lord given to David through Nathan (2 Samuel 7:17), we should assume that David went into the tent where the ark was kept.1 He was allowed to enter this tent on account of his priestly status (see 2 Samuel 6:17).2
18 Then King David went in and sat before the LORD and said, “Who am I, O Lord GOD, and what is my house, that you have brought me thus far?