Sometimes, the floor is the safest place to be, and other times, it can be the least. If you are in a closed area (such as court or an office) and you hear gunfire, you should drop to the floor with your feet pointed towards the source of the shots. This will minimize the area where you could be hit, and reduce the exposure of your most vital areas. If you are in an open area (such as a park) and you hear gunfire, you should seek cover if possible (and not just concealment -- read more here), and then drop to the ground if necessary.
In arm's-length combat, however, you should avoid the ground if at all possible. It is common to hear that "90% of all fights end up on the ground." This "statistic" comes from a study performed by the Los Angeles Police Department in 1997 (read more here), and is not at all accurate. While it is true that being trained in ground combat techniques can help minimize injury when you find yourself on the ground, you should not prefer this scenario. I know some martial arts instructors who will teach their students to take an opponent to the ground and then join him* there. I would strongly advise against this. Putting an assailant on the ground is a great idea, but you should keep your feet if you can -- this makes it easier to escape or to capitalize on your opponent's disadvantaged position. In addition, your assailant may have friends nearby, and voluntarily "going to the ground" puts you at their mercy. By all means, learn to fight on the ground, but use those skills only as a last resort.
In arm's-length combat, however, you should avoid the ground if at all possible. It is common to hear that "90% of all fights end up on the ground." This "statistic" comes from a study performed by the Los Angeles Police Department in 1997 (read more here), and is not at all accurate. While it is true that being trained in ground combat techniques can help minimize injury when you find yourself on the ground, you should not prefer this scenario. I know some martial arts instructors who will teach their students to take an opponent to the ground and then join him* there. I would strongly advise against this. Putting an assailant on the ground is a great idea, but you should keep your feet if you can -- this makes it easier to escape or to capitalize on your opponent's disadvantaged position. In addition, your assailant may have friends nearby, and voluntarily "going to the ground" puts you at their mercy. By all means, learn to fight on the ground, but use those skills only as a last resort.
* I tend to use the masculine pronoun in these posts simply because most attackers are men, and not to be sexist or as a traitor to my own gender.