java.lang.Integer.parseInt won’t take 0xFFFFFFFF

Like the title says I have this code

needleColor = Integer.parseInt(mPrefs.getString("color_key", "-1"));

that throws NumberFormatException stating “0xFFFFFFFF is not a valid integer”. This code worked fine up until eclipse crashed and I wound up completely removing eclipse and re-downloading the adk.

Looking at the documentation the colors are represented as ints and the value is -1. So it’s a valid int…


Integer.parseInt doesn’t process the 0x prefix — it expects you to pass in the bare digits, and the radix. Integer.decode would probably do what you want, though.

Leave a Reply

Your email address will not be published. Required fields are marked *