The traders that bought Joseph brought him down to Egypt and sold him to an Egyptian official named Potiphar. God blessed Joseph and Potiphar realized this, and put Joseph in charge. Now, Potiphars wife really liked how handsome Joseph was and one day, when no one else was around, she tried to kiss him. Joseph kept insisting that it wouldn't be right and God wouldn't like it. Potiphar's wife didn't understand, because Joseph was all alone in a foreign land and his god shouldn't care but Joseph insisted because he knew God and knew He wouldn't like it.
So Potiphars wife had Joseph thrown in jail and once again, it looked like God's plans were ruined. But once again, God blessed Joseph and Joseph was put in charge of the prison. One day, two men were put in jail, Pharaoh's baker and Pharaoh's cup bearer. That night, they both had strange dreams and told Joseph about them in the morning.
Because Joseph still knew God, even in a strange land, he talked to God and God told him what the dreams meant. The baker dreamt that he had three baskets of bread and the birds came and ate it all up. His dream meant that in three days, he would be executed. The cup bearer dreamt of a grapevine, which he squeezed into juice for the pharaoh. His dream meant that in three days, he would get his old job back. Sure enough, in three days, the baker was executed and the cup bearer went back to work.
No matter the situation, we can always know God. In fact, God wants us to know Him in every situation, the good and especially the bad.