Tag Archives: unique device identifiers

Android unique device identifiers, serial number and ANDROID_ID

There has been some discussions about unique device identifiers in Android.

Basically there are 3 main options (starting from the least recommended):

MAC Address or TelephonyManager –  not recomended

The mac address from WiFi or Bluetooth, however this is the best option as some devices does not have the specific hardware(wifi or bt), or depending on its status (off/disabled) mac cannot be obtained.

ANDROID_ID (from API 3) – can change after system update

Settings.Secure.ANDROID_ID is

A 64-bit number (as a hex string) that is randomly generated on the device’s first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

Constant Value: “android_id”
It can be obtained grammatically using this:
Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)


Serial Number (from API 9) – recommended

android.os.Build.SERIAL  –

A hardware serial number, if available. Alphanumeric only, case-insensitive.

is the serial number you see in the DDMS view in Eclipse or from the command “adb devices”. This can be obtained pragmatically from



Its simple if you do not care to identify hardware  but installation go for ANDROID_ID, otherwise use android.os.Build.SERIAL.


Here is a simple example of serial number and ANDROID_ID before and after android update.

Executed command:

adb devices

Executed code:

Log.i("TEST","android.os.Build.SERIAL: " + android.os.Build.SERIAL);
Log.i("TEST","Settings.Secure.ANDROID_ID: " + Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));

On Build: jwr66v


List of devices attached
0039f663df121556        device


I/TAG(8122): android.os.Build.SERIAL: 0039f663df121556
I/TAG(8122): Settings.Secure.ANDROID_ID: 5b79c0300c556842

On Build: jwr66y


List of devices attached
0039f663df121556        device


I/TAG(2861): android.os.Build.SERIAL: 0039f663df121556
I/TAG(2861): Settings.Secure.ANDROID_ID: 3dcc3d9765e7f1db