What was the environment of the pterodactyl?

Well first off this is posted in 'birds' and these animal were flying reptiles, not birds. Secondly, although in common use, the term 'pterdactyl' is incorrect and you should use 'pterosaur'. Thirdly, I'm afriad this question is so general as to be redundant, you might as well ask about the envirnments that mammals live in or birds - there were many ptersaur species and they lived around coasts, over oceans, inland, on plains and in forests and probably pretty much everywhere.