Yes it would work as you described. That is called a pull-down resistor because is assures that when the contact is open the digital input is at logic state 0. Usually you can use a 10 KΩ resistor.