I've often confused the difference between "awhile" and "a while" so I decided to do some research and here's what Brian's Common English Errors Website had to say about this:
When “awhile” is spelled as a single word, it is an adverb meaning “for a time."
So you would say:
"My Prince Charming was bored with me awhile."
But when “while” is the object of a prepositional phrase the “while” must be separated from the “a.”
Then you would say:
"Did you have Prince Charming's CD for a while or only after you broke up?"
The site also makes not that if the preposition “for” were lacking in this sentence, “awhile” could be used in this way:
"Did you have Prince Charming's CD awhile?"