When I was working in my country, away from my hometown, where Muslims are in minority, I had to rent a room with a non-Muslim family. I felt I could not tell them my faith, because the least they would have done was to turn me out. It would have been very difficult for me to find accommodation. I had to hide the fact that I am a Muslim throughout my stay with them. Was my action wrong?
Necessities are measured by their particular circumstances. It is permissible for a Muslim to hide his faith when he is in a situation where he may be in danger if it is known that he is a Muslim. In your circumstances, you are the best judge on what to do in order to be safe and to have a reasonable living. I understand that you were in very difficult circumstances, but the degree of difficulty and the alternatives available to you are something that I cannot judge properly without much more detailed information.
If it was easy for you to seek accommodation with a Muslim family, even though it may be further away in the city, the situation would not then be one of emergency. If that was not possible, then a less difficult arrangement might still have been found. It is all a matter of weighing up alternatives. What you should do now is to seek God’s forgiveness and to be more determined to own up to the fact that you believe in Islam.