# Telephony.Threads

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Threads

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/provider/Telephony.Threads "View this page in Java")  

```
class Threads : Telephony.ThreadsColumns
```

|---|--------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                           ||
| ↳ | [android.provider.Telephony.Threads](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#) |

Helper functions for the "threads" table used by MMS and SMS. Thread IDs are determined by the participants in a conversation and can be used to match both SMS and MMS messages. To avoid issues where applications might cache a thread ID, the thread ID of a deleted thread must not be reused to point at a new thread.

## Summary

|                                                                                                                     Constants                                                                                                                      ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [BROADCAST_THREAD](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#BROADCAST_THREAD:kotlin.Int) Thread type: broadcast thread. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [COMMON_THREAD](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#COMMON_THREAD:kotlin.Int) Thread type: common thread.          |

| Inherited constants ||
|---|---|
| From class[ThreadsColumns](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns) |----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ARCHIVED](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#ARCHIVED:kotlin.String) <br /> If the thread is archived Type: INTEGER (boolean) <br />                                                                                                                                                                                                                                                               | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [DATE](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#DATE:kotlin.String) <br /> The date at which the thread was created. Type: INTEGER (long) <br />                                                                                                                                                                                                                                                          | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ERROR](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#ERROR:kotlin.String) <br /> Indicates whether there is a transmission error in the thread. Type: INTEGER <br />                                                                                                                                                                                                                                          | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [HAS_ATTACHMENT](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#HAS_ATTACHMENT:kotlin.String) <br /> Indicates whether this thread contains any attachments. Type: INTEGER <br />                                                                                                                                                                                                                               | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [MESSAGE_COUNT](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#MESSAGE_COUNT:kotlin.String) <br /> The message count of the thread. Type: INTEGER <br />                                                                                                                                                                                                                                                        | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [READ](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#READ:kotlin.String) <br /> Indicates whether all messages of the thread have been read. Type: INTEGER <br />                                                                                                                                                                                                                                              | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [RECIPIENT_IDS](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#RECIPIENT_IDS:kotlin.String) <br /> A string encoding of the recipient IDs of the recipients of the message, in numerical order and separated by spaces. Type: TEXT <br />                                                                                                                                                                       | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [SNIPPET](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#SNIPPET:kotlin.String) <br /> The snippet of the latest message in the thread. Type: TEXT <br />                                                                                                                                                                                                                                                       | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [SNIPPET_CHARSET](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#SNIPPET_CHARSET:kotlin.String) <br /> The charset of the snippet. Type: INTEGER <br />                                                                                                                                                                                                                                                         | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [TYPE](https://developer.android.com/reference/kotlin/android/provider/Telephony.ThreadsColumns#TYPE:kotlin.String) <br /> Type of the thread, either[Threads.COMMON_THREAD](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#COMMON_THREAD:kotlin.Int)or[Threads.BROADCAST_THREAD](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#BROADCAST_THREAD:kotlin.Int). Type: INTEGER <br /> | ||
| From class[BaseColumns](https://developer.android.com/reference/kotlin/android/provider/BaseColumns) |----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [_COUNT](https://developer.android.com/reference/kotlin/android/provider/BaseColumns#_COUNT:kotlin.String) <br /> The count of rows in a directory. Type: INTEGER <br /> | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [_ID](https://developer.android.com/reference/kotlin/android/provider/BaseColumns#_ID:kotlin.String) <br /> The unique ID for a row. Type: INTEGER (long) <br />         | ||

|                                                                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                                                                 ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getOrCreateThreadId](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#getOrCreateThreadId(android.content.Context,%20kotlin.String))`(`context:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!`, `recipient:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` This is a single-recipient version of`getOrCreateThreadId`.                                                                                                              |
| static[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getOrCreateThreadId](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#getOrCreateThreadId(android.content.Context,%20kotlin.collections.MutableSet))`(`context:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!`, `recipients:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>!`)` Given a set of recipients return its thread ID. |

|                                                                                                                                            Properties                                                                                                                                             ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)! | [CONTENT_URI](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#CONTENT_URI:android.net.Uri) The`content://`style URL for this table, by conversation.                        |
| static[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)! | [OBSOLETE_THREADS_URI](https://developer.android.com/reference/kotlin/android/provider/Telephony.Threads#OBSOLETE_THREADS_URI:android.net.Uri) The`content://`style URL for this table, for obsolete threads. |

## Constants

### BROADCAST_THREAD

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val BROADCAST_THREAD: Int
```

Thread type: broadcast thread.  

    Value: 1

### COMMON_THREAD

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val COMMON_THREAD: Int
```

Thread type: common thread.  

    Value: 0

## Public methods

### getOrCreateThreadId

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static fun getOrCreateThreadId(
    context: Context!, 
    recipient: String!
): Long
```

This is a single-recipient version of`getOrCreateThreadId`. It's convenient for use with SMS messages.

|                                                            Parameters                                                            ||
|-------------|---------------------------------------------------------------------------------------------------------------------|
| `context`   | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!:the context object to use. |
| `recipient` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:the recipient to send to.         |

### getOrCreateThreadId

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static fun getOrCreateThreadId(
    context: Context!, 
    recipients: MutableSet<String!>!
): Long
```

Given a set of recipients return its thread ID.

If a thread exists containing the provided participants, return its thread ID. Otherwise, this will create a new thread containing the provided participants and return its ID.

## Properties

### CONTENT_URI

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val CONTENT_URI: Uri!
```

The`content://`style URL for this table, by conversation.  

### OBSOLETE_THREADS_URI

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val OBSOLETE_THREADS_URI: Uri!
```

The`content://`style URL for this table, for obsolete threads.