4

What I Want: I want to have unique Identifier for SMS and Contacts in android, like ID's. I want them to be unique. So that whenever I take backup of SMS or Contacts, it saves the backup with this identifier. Upon Restoring, this identifier should be compare with the SMS or contacts on the device to avoid duplication. An example is UID's in Symbian, they are always unique for every entry in Database for SMS or Contacts.

What is the problem: The problem is that I am unable to find any unique identifier so far. All I get are incremental ID's, which in some cases start again from initial value and keeps on incrementing. So, they do not act as unique in this scenario.

For example: In case of SMS, the ID can be treated as UID. But, upon deleting all messages and again having a new entry of message, Android reassigns ID to this entry starting from 1.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Khawar
  • 5,197
  • 4
  • 28
  • 52

1 Answers1

3

Take some unique parts of your SMS like the senders phone number and the current time stamp and create an MD5 hash of those values. Now you have a unique identifier for your messages and contacts.

Here is a question now how to generate a MD5 hash in Java.

Community
  • 1
  • 1
Octavian Helm
  • 39,405
  • 19
  • 98
  • 102