Reputation: 2055
In my android application i want to create uuid for identifier primary key in each table entry so that it should be unique among 1000's of users in my server.So whenever a new record is inserted a random uuid/guid should be generated with the device id,current timestamp,etc. to the identifier field instead of a auto-generated integer value.How can i do that in android? Please help me.
Upvotes: 1
Views: 4302
Reputation: 199805
To build a unique UUID, you should use the UUID class:
String uuid = UUID.randomUUID().toString();
It is already based on the current timestamp and does not rely on any personally identifiably information such as device id (most of which require a runtime permission).
Upvotes: 1