user291701
user291701

Reputation: 39721

Is Build.DEVICE constant for the lifetime of a device?

I'd like to (loosely) tie a file to a particular device, looking for some identifiers that are static per device:

http://developer.android.com/reference/android/os/Build.html#DEVICE

I'm hoping that:

Build.DEVICE

is constant? For example, no system upgrades or hardware changes would modify that value?

Thanks

Upvotes: 1

Views: 1462

Answers (2)

Franci Penov
Franci Penov

Reputation: 76011

Build.DEVICE is likely to stay unchanged, as @zrgiu said. However, it's not unique per device, so two devices that are the same will have the same value for it.

If you are looking for a device-specific value, Build.SERIAL is better option. Or at least it would've been, if it was guaranteed to exist for all devices.

Another alternative is Settings.Secure.ANDROID_ID, which is guaranteed to exist on each device. Sadly, that one is not guaranteed to be unique across devices (even though the algorithm to generate it will make reasonable attempt at it). This one also will not be persisted across factory reset, if that is important to you.

There is no value that is guaranteed to be there, to be unique per device, and to be persisted across factory reset. You can pick any two out of these three... :-)

Upvotes: 2

zrgiu
zrgiu

Reputation: 6342

The Build.DEVICE can be changed on a system upgrade/replace but it's very unlikely to be modified (unless people making custom ROMs want to give you a hard time, but that's rare). It's safe to assume that the constant remains the same for the lifetime of the device, and use it however you need.

Upvotes: 0

Related Questions