Past Perfect SimpleThey had lived in New York for 3 years before they moved to Seattle. (up to the time they moved to Seattle)
Past Perfect ContinuousShe had been studying for 4 hours when he arrived. (The four hours directly before he arrived)
Now, let's take a look at the specific differences between the two forms:
Past Perfect Simple is used to express finished activity before a specific point of time in the past.
Example: He had already eaten when his wife came home.
Past Perfect Continuous is used to express continuous/progressive activity up to a specific point of time in the past.
Example: They had been waiting for 2 hours before their friends finally arrived.