I normally use the following idiom to check if a String can be converted to an integer.
public boolean isInteger( String input ) { try { Integer.
If you are using the Android API you can use:
TextUtils.isDigitsOnly(str);