Yesterday I wrote "gray" in the meaning of the color, but my friend corrected me and told me to write "grey". Today I checked in the dictionary and I found that they are both correct for the same meaning. So, now I just have doubt which one of them is more common in use.
You're right, they are both correct. Which one is better depends on who you ask. In the USA, it's spelled "gray" and in the UK, it's spelled "grey". A fun mnemonic for this is A for America, E for England. Plenty of other words do this also. Color/colour, fiber/fibre, liter/litre, etc.
The population of the USA is higher so gray is technically more common. Use the one that matches the country you're in and the people you're writing for.
If you're in neither country, it doesn't really matter which one you use. Pick one you like and stick with it.