January 14, 2017

Android How to Get Phone Unique Device Id

By Lalit Vasan

Sometimes it is required to get the unique ID of android device while developing the android application. This is necessary in cases when the you wants to track the unique device installations of the application. There are many ways to get android device unique ID so below method is a relevant way to get ANDROID_ID via Secure class.
Below method returns 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.)

public String getDeviceId(Context context){
    // returns 64-bit unique string
    return Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);


Enjoy Coding and Share Knowledge