i get android id
GB.AndroidId=CheckDataNull(Settings.Secure.getString(getApplicationContext().getContentResolver(),Settings.Secure.ANDROID_ID));
result is a8606c9f06af341f = this is hex value
i want to convert it to decimal value
result must be 12132816826403861535
converted online with this site https://www.rapidtables.com/convert/number/hex-to-decimal.html
i already tried this code
int decimal=Integer.parseInt(hex,16);
but get an error
java.lang.NumberFormatException: Invalid int: "a8606c9f06af341f"
then i tried Converting Hexadecimal String to Decimal Integer it's also don't work
this code works but output is different
input = a8606c9f06af341f
output =859058534
public static int hex2decimal(String s) {
String digits = "0123456789ABCDEF";
s = s.toUpperCase();
int val = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
int d = digits.indexOf(c);
val = 16*val + d;
}
return val;
}
QUESTION : how can i get correct value ?
input=a8606c9f06af341f
output=12132816826403861535
Correct Answer is
BigInteger decimal = new BigInteger(hex , 16);