I have a preferences.xml that looks like this:
In your preferences xml you can add an option android:numeric with the value "integer". This way the user should only be able to enter a valid integer value.
When loading the setting you should try to parse it to a number yourself (as all values are stored as Strings (@mbaird below)):
try {
float val = Float.parseFloat(sp.getString("sample", "3.0f"));
} catch (NumberFormatException e) {
// "sample" was not an integer value
// You should probably start settings again
}