0

When device is factory reset, This ID is changing every time. MAC address also not accessible always. I want a unique android id. which is always a unique value even though device is reset.

1 Answers1

2

You should read Best practices for unique identifiers and THIS topic, but in short: there is no reliable variable/value in system across different manufacturers and versions, definitely not for reset case. If you want persist, unique identifier for your app then use UUID.randomUUID().toString() and store this value in e.g. SharedPreferences. It will persist as long as your app will be installed.

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • I am developing an app having device based license registration. so if the device is reset or app is reinstalled also license will validate throughout lifetime. – Libin K Thankachan Jun 14 '21 at 07:10
  • if user is again installed app on same device ,previous license details will fetch automatically from our servers. – Libin K Thankachan Jun 14 '21 at 07:10
  • 1
    well, there is no option for persist unique id on android, especially for reset case. you should build a system that connects licence with account, not device. then first log will bind account to generated instance `UUID`, any other log-in should check this `UUID` and for another app instance with same credentials and already stored, different `UUID` should ask user for allowing re-binding licence to new `UUID` (previous would be overwritten, any previous session should be broken) – snachmsm Jun 14 '21 at 07:26