Retrieves the value of key from the preferences.
The preference value, or defaultValue if the key does not exist.