The Sefarim (first Rama in Orah Haim) discuss "Shiviti Hashem Lenegdi Tamid" in other words Devekut Hamachshava. Does anyone have an Etza to reach this amazing Maala?
The Mishna B'rura (1:4) writes that a person should constantly internalize that he is standing before the Almighty, which he in fact is. He further quotes the AriZal that a person should visualize the Tetragrammaton with the vowelization of the word יִרְאָה as a means of fulfilling the verse "שויתי ה' לנגדי תמיד" ("I set HaShem before me constantly", T'hillim 16:8).
As far as achieving the trait of d'veikus hamachshava in its quintessence, the remainder of this answer will be confined to the approach of the M'silas Y'sharim as discussed in the chapter on k'dusha ("holiness"). To fully achieve constant d'veikus hamachshava in its perfect form, one must first obtain the prerequisite traits of watchfulness from obvious sins, zeal to perform good deeds, cleanliness from any trace of sin, separation from unnecessary worldly indulgences or social involvement, purity of motivation in all spiritual thoughts, speech, and deeds, saintly fulfillment of all mitzvos to the maximum extent possible in every imaginable regard (beyond that which is strictly necessary to fulfill one's obligations), total humility in thought, speech, and deed, and an ever-present sense of awe of the Almighty and revulsion towards the possibility of violating His will.
If, after having undergone all these preparations, he steadfastly pursues with strong love and great fear, the contemplation of the greatness of the Blessed One and the might of His majesty, he will separate himself little by little from earthy considerations and in all his actions and movements will direct his heart to the intimacies of true communion until there is conferred upon him a spirit from on high and the Blessed One causes His Name to dwell with him as He does with all of His Holy ones. He will then be in actuality like an angel of G-d, and all of his actions, even the lowly, physical ones, will be accounted as sacrifices and Divine service.
To reach this level of k'dusha, which as described by the Ramchal is essentially the same as having constant d'veikus hamachshava and making all of one's thoughts, speech, and deeds (even those related to otherwise mundane activities) totally l'shem shamayim, a person must strive for this goal to the best of his ability, and then:
In the end, the Holy One Blessed be He leads him upon the path that he desires to follow, causes His Holiness to rest upon him, and sanctifies him, thus enabling him to maintain a constant intimacy with Him, the Blessed One. Where his nature hinders him, the Blessed One will aid and assist him, as it is stated (Psalms 84:12), "He does not withhold good from those who walk in purity."
The Ramchal provides some specific advice on beginning the process of striving for holiness:
It is to be seen that the means of acquiring this trait are much separation, intense contemplation of the secrets of Divine governance and the mysteries of creation, and understanding of the majesty of the Blessed One and His excellence, to the point where one cleaves closely to Him and is capable of performing physical activities with the same motivation with which it befits the Priest to slaughter the sacrificial animal, receive its blood, and sprinkle it in order to receive from the Blessed One the blessing of life and peace. Without the above orientation one will find it impossible to attain Holiness, and regardless of what level he may have reached, he will nonetheless remain earthy and physical, like all other men.
What assists one towards the acquisition of this trait is much solitude and separation, which, by eliminating the claims upon a person, allows his soul to grow in strength and to unite itself with the Creator. The deterrents to Holiness are a lack of true understanding and much association with people; for earthiness finds its counterpart and takes on new strength, and the soul remains trapped within it, unable to escape.
Although a person who has not yet fully achieved the prerequisite levels of spiritual development will never be able to fully or perfectly achieve d'veikus hamachshava in it's absolute form, he should still strive for whatever degree of d'veikus hamachshava he can achieve, as per Ray's answer and the beginning of this answer. (See also this question).
From the perspective of the Zohar, Devekus is mental attachment to Hashem. The way to achieve this is both through intention to be connected to Hashem, and performing the mitzvos. Additionally, the verses of Torah recited during learning or davening serve as vessels to connect to Hashem, which can help a person increase his mental attachment and awareness that "Ain Od Milvado" - there is nothing but Him. The more one contemplates that Hashem is above all description and that the universe, while a magnificant creation, is completely null and void compared to the Supreme King of Kings, HaKadosh Baruch Hu, the more one can stand in complete awe and reverence to his Creator. This is another take on the concepts posted previously, but I just wanted to add another dimension.
The Chafetz Chaim explains this verse as follows (from Shem Olam part 2 ch.10): "the general principle, is for every good person to contemplate always how H-shem's presence fills the world, and that he is standing before Him to do His will. This is what is meant by 'shivisi H'..', that 'I have constantly contemplated that I am standing before G-d to do His will", and this is what G-d said to Avraham - "Walk before Me and be Perfect.." (Bereishis 17:1), which means contemplate always that you are standing before Me."
(Shaarei Kedusha part 4 gate 3 also says some things about this related to attaining ruach hakodesh but since it is in the first halacha of the Sh'A then the Rama's main intent is probably for the simple meaning.)
however "an ignorant man cannot be pious" (pirkei avot). One must be growing in his torah study otherwise all this has no foothold