9

Can anybody please tell me the length for device UDID in Android, because I got the UDID in android and it is only 16 characters, but the iPhone UDID length is 40.

I am using the following code to detect the ID:

id = android.provider.Settings.System.getString(super.getContentResolver(),
    android.provider.Settings.Secure.ANDROID_ID);
RivieraKid
  • 5,923
  • 4
  • 38
  • 47
SampathKumar
  • 2,525
  • 8
  • 47
  • 82
  • how are you obtaining the uuid? Also I don't think a specific size is enforced, so it would be safer if you did not assume that the length will be the same across all Android devices. – FoamyGuy Jul 20 '12 at 14:21
  • id = android.provider.Settings.System.getString(super.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); – SampathKumar Jul 20 '12 at 14:22
  • i just analyse the length (UDID) for iphone and android – SampathKumar Jul 20 '12 at 14:24
  • oh, Im sorry I did not realize that you were the asker. Don't post in an answer edit your question to include the code. – FoamyGuy Jul 20 '12 at 14:25

2 Answers2

11

The Android ID is

UP TO 16 characters long

since leading zeroes are not pretended at least in some versions of Android that appear in the wild. Take a look at this answer to a similar question for why that is: https://stackoverflow.com/a/29890124/2066744

The docs specify it as a 64-bit number (expressed as a hexadecimal string) here: https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

mschwaig
  • 551
  • 6
  • 19
8

i have two device using this code

String device_id =  Secure.getString(getContentResolver(), Secure.ANDROID_ID);
Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
  • be aware that this method of getting a UID is not bullet proof. See: [Is Secure.ANDROID_ID unique for each device?](http://stackoverflow.com/questions/4799394/is-secure-android-id-unique-for-each-device) and [Is there a unique Android device ID?](http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id) for reference. Use at your own risk =) – FoamyGuy Jul 20 '12 at 14:26
  • Got a 15 as well. – Steve Moretz May 13 '19 at 05:29