英文:
Creating unique random ID
问题
这会为Cloud Firestore创建一个唯一的用户ID吗?
Build.BOARD.length()+"" + Build.BRAND + Build.DEVICE + Build.DISPLAY.length()%10
+ Build.HOST.length()%10 + Build.ID.length()+ Build.MANUFACTURER.length()%10
+ Build.MODEL.length()%10 + Build.PRODUCT.length()%10 + Build.TAGS.length()%
10 + Build.TYPE + Build.USER.length()%10;
英文:
Would this create a unique user ID for Cloud Firestore?
Build.BOARD.length()+"" + Build.BRAND + Build.DEVICE + Build.DISPLAY.length() % 10
+ Build.HOST.length() % 10 + Build.ID.length() + Build.MANUFACTURER.length() % 10
+ Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10+ Build.TAGS.length() %
10 + Build.TYPE + Build.USER.length() % 10;
答案1
得分: 2
UUID
你考虑过使用通用唯一标识符(UUID)吗,例如通过UUID.randomUUID()
方法返回的UUID?
UUID s = UUID.randomUUID();
System.out.println(s);
输出类似于
d918666e-6ebb-4700-99fe-c3279ba2daff
还有其他可用的UUID方法。但不能保证它绝对唯一,只是极高的概率上是唯一的。
英文:
UUID
Did you consider using a universally unique identifier (UUID) such as that returned by UUID.randomUUID()
?
UUID s = UUID.randomUUID();
System.out.println(s);
Prints something like
d918666e-6ebb-4700-99fe-c3279ba2daff
Additional UUID methods are also available. But no guarantees it would be unique. Just an extremely high probability that it is.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论