Furqan
Furqan

Reputation: 895

Is UUID.randomUUID() return unique value for each time?

I am doing R&D on getting unique device ID for android device but none of the solution seems perfect.

UUID.randomUUID().toString(); seems a good solution but I am wondering that in each call does this function return unique value? If it is true than it is good else I think it is also not a good solution.

R&D links on getting unique device ID: 1: http://www.ssaurel.com/blog/how-to-retrieve-an-unique-id-to-identify-android-devices/ 2: Is there a unique Android device ID?

Upvotes: 0

Views: 4792

Answers (2)

Abdul Waheed
Abdul Waheed

Reputation: 4688

There are four different basic types of UUIDs:

Time-based, DCE security, name-based, and randomly generated UUIDs.

As far as chances are concerned, yes there is a possibility for same UUID for 2 devices. You can make it by other ways. For example

1) Get the UUID first and appened date time with it that will make completely unique id

2)Get the UUID first and appened date time and also append IMEI nuber with it that will make completely unique id

For more information regarding UUID you may refer below link

http://tools.ietf.org/rfc/rfc4122.txt

Upvotes: 3

Henry
Henry

Reputation: 43798

For all practical purposes the result of UUID.randomUUID() is unique. However, since there are only finitely many UUIDs it is clear that there will be repetitions eventually.

Upvotes: 1

Related Questions