Android SMS _id

I searched Google several times, but could not find what I was looking for. Android assigns an identifier to each sms message. I wanted to know if this identifier is always unique? Can I rely on it to identify sms messages, or should I designate my own?

Thanks:)

0
source share
3 answers

Since it uses SQLite, i.e. a relational database, it is not possible to have a duplicate identifier.

+2
source

Check the source code of MmsSmsDatabaseHelper and pay attention to the implementation of the createSmsTables method:

 private void createSmsTables(SQLiteDatabase db) { // NB: Whenever the columns here are changed, the columns in // {@ref MmsSmsProvider} must be changed to match. db.execSQL("CREATE TABLE sms (" + "_id INTEGER PRIMARY KEY," + "thread_id INTEGER," + "address TEXT," + "person INTEGER," + "date INTEGER," + "date_sent INTEGER DEFAULT 0," + "protocol INTEGER," + "read INTEGER DEFAULT 0," + "status INTEGER DEFAULT -1," + "type INTEGER," + "reply_path_present INTEGER," + "subject TEXT," + "body TEXT," + "service_center TEXT," + "locked INTEGER DEFAULT 0," + "error_code INTEGER DEFAULT 0," + "seen INTEGER DEFAULT 0" + ");"); /* rest of implementation not shown */ } 

_id that is assigned to each sms message is a PRIMARY KEY , so yes, it uniquely identifies each sms message.

+4
source

SMS_ID is always unique for each message. But there is another column called Thread_ID, which is common to each conversation, i.e. the conversation itself on the android phone gave a unique Thread_Id. But each message in this particular stream has a unique SMS_ID

+2
source

All Articles