Theoretically, I don't think this method will return repeated UUIDs, even from different devices.

Let's check the documentation of android: http://developer.android.com/reference/java/util/UUID.html. It says "Generates a variant 2, version 4 (randomly generated number) UUID as per RFC 4122."

Even in JDK documentation http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html , it says they are implementing RFC 4122.

And in RFC 4122, http://www.ietf.org/rfc/rfc4122.txt, it says "A UUID is 128 bits long, and can guarantee uniqueness across space and time."

Wikipedia also calculates the probability of duplicates of RandomUUID: http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates

There is a guy here ( http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) states that "We (i.e. my team at work) have been using the Java Util UUID class for UUIDs across JVMs."

However, I still can see a lot of worries that the Java randomUUID will not be unique.

First of all, let us check the wikipedia: http://en.wikipedia.org/wiki/Universally_unique_identifier. It says java is not using MAC address for generating UUID "due to lack of means to access MAC addresses using pure Java before version 6". It also gives opensource UUID generation tools as http://johannburkard.de/software/uuid/ and https://github.com/cowtowncoder/java-uuid-generator. Not sure not using MAC address will make them not unique.

Some people here ( http://www.coderanch.com/t/385404/java/java/UUID-Uniqueness-JVMs) also say they are using a central control to generate UUID.

This link( http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid ) says "implementation to contain subtle bugs that ruin all this (see OpenSSH key generation bug)".

This link( http://stackoverflow.com/questions/6505837/is-oracles-sys-guid-uuid-rfc-4122-compliant) says "SYS_GUID is Oracle's equivalent of UUID. It is globally unique. However, it is not compliant to RFC 4122".

Anyway, I do not find any evidence that says UUID.randomUUID() will repeat, even from different machines.
As it says here (http://stackoverflow.com/questions/2513573/how-good-is-javas-uuid-randomuuid), "I don't think there's any concrete reason to worry about Java UUIDs's randomness."

However, if we are building very critical distributed applications with a lot of data, maybe, we can consider using MAC address algorithm, or using central UUID generator.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. apk反编译和重新打包
  2. MonoDroid学习笔记(一)―― 搭建MonoDroid
  3. Google+ 手機App中文介面新登場, Android
  4. Android开发学习指南,同时庆祝第二款手机
  5. Android下DLNA开发简介
  6. Android使用huffman编码进行图片压缩
  7. 【Android(安卓)学习记录】:针对Android(
  8. 如何确定Android中刚修改后的c/c++是否编
  9. SPB Brain Evolution 每天的頭腦體操,全球
  10. Android基于蓝牙串口编程实现HC-05通讯