Is Secure.ANDROID_ID unique for each device? Is Secure.ANDROID_ID unique for each device? android android

Is Secure.ANDROID_ID unique for each device?


Check into this thread,. However you should be careful as it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone. Also it appears as if some manufacturers have had issues with their phones having duplicate numbers thread. Depending on what your trying to do, I probably wouldnt use this as a UID.


With Android O the behaviour of the ANDROID_ID will change. The ANDROID_ID will be different per app per user on the phone.

Taken from: https://android-developers.googleblog.com/2017/04/changes-to-device-identifiers-in.html

Android ID

In O, Android ID (Settings.Secure.ANDROID_ID or SSAID) has a different value for each app and each user on the device. Developers requiring a device-scoped identifier, should instead use a resettable identifier, such as Advertising ID, giving users more control. Advertising ID also provides a user-facing setting to limit ad tracking.

Additionally in Android O:

  • The ANDROID_ID value won't change on package uninstall/reinstall, aslong as the package name and signing key are the same. Apps can relyon this value to maintain state across reinstalls.
  • If an app was installed on a device running an earlier version ofAndroid, the Android ID remains the same when the device isupdated to Android O, unless the app is uninstalled andreinstalled.
  • The Android ID value only changes if the device is factoryreset or if the signing key rotates between uninstall and
    reinstall events.
  • This change is only required for device manufacturersshipping with Google Play services and Advertising ID. Otherdevice manufacturers may provide an alternative resettableID or continue to provide ANDROID ID.


So if you want something unique to the device itself, TM.getDeviceId() should be sufficient.

Here is the code which shows how to get Telephony manager ID. The android Device ID that you are using can change on factory settings and also some manufacturers have issue in giving unique id.

TelephonyManager tm =         (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);String androidId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);Log.d("ID", "Android ID: " + androidId);Log.d("ID", "Device ID : " + tm.getDeviceId());

Be sure to take permissions for TelephonyManager by using

<uses-permission android:name="android.permission.READ_PHONE_STATE" />