# SimPhonebookContract.SimRecords

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

# SimRecords

*** ** * ** ***

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

```
class SimRecords
```

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

Constants for the contact records on a SIM card.

### Data

<br />

Data is stored in a specific elementary file on a specific SIM card and these are isolated from each other. SIM cards are identified by their subscription ID. SIM cards may not support all or even any of the elementary file types. A SIM will have constraints on the values of the data that can be stored in each elementary file. The available SIMs, their supported elementary file types and the constraints on the data can be discovered by querying[ElementaryFiles.CONTENT_URI](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#CONTENT_URI:android.net.Uri). Each elementary file has a fixed capacity for the number of records that may be stored. This can be determined from the value of the[ElementaryFiles.MAX_RECORDS](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#MAX_RECORDS:kotlin.String)column.

The[SimRecords.PHONE_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#PHONE_NUMBER:kotlin.String)column can only contain dialable characters and this applies regardless of the SIM that is being used. See[android.telephony.PhoneNumberUtils#isDialable(char)](https://developer.android.com/reference/kotlin/android/telephony/PhoneNumberUtils.html#isDialable(kotlin.Char))for more details. Additionally the phone number can contain at most[ElementaryFiles.PHONE_NUMBER_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#PHONE_NUMBER_MAX_LENGTH:kotlin.String)characters. The[SimRecords.NAME](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#NAME:kotlin.String)column can contain at most[ElementaryFiles.NAME_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH:kotlin.String)bytes when it is encoded for storage on the SIM. Encoding is done internally and so the name should be provided to these provider APIs as a Java String but the number of bytes required to encode it for storage will vary depending on the characters it contains. This length can be determined by calling[SimRecords.getEncodedNameLength(ContentResolver, String)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String)).

### Operations

:   **Insert**
:   **Update**
:   **Delete**
:   **Query**

## Summary

|                                                                                                                                                                                                                                                                                                 Constants                                                                                                                                                                                                                                                                                                  ||
|----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [CONTENT_ITEM_TYPE](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#CONTENT_ITEM_TYPE:kotlin.String) The MIME type of a CONTENT_URI subdirectory of a single SIM record.                                                                                                                                                                                                                                                                                           |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [CONTENT_TYPE](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#CONTENT_TYPE:kotlin.String) The MIME type of CONTENT_URI providing a directory of SIM records.                                                                                                                                                                                                                                                                                                      |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ELEMENTARY_FILE_TYPE](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#ELEMENTARY_FILE_TYPE:kotlin.String) The type of the elementary file the record is from.                                                                                                                                                                                                                                                                                                     |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)       | [ERROR_NAME_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#ERROR_NAME_UNSUPPORTED:kotlin.Int) Value returned from[getEncodedNameLength(android.content.ContentResolver,java.lang.String)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String))when the name length could not be determined because the name could not be encoded. |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [NAME](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#NAME:kotlin.String) The name for this record.                                                                                                                                                                                                                                                                                                                                                               |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [PHONE_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#PHONE_NUMBER:kotlin.String) The phone number for this record.                                                                                                                                                                                                                                                                                                                                       |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [RECORD_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER:kotlin.String) The 1-based offset of the record in the elementary file that contains it.                                                                                                                                                                                                                                                                                             |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [SUBSCRIPTION_ID](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#SUBSCRIPTION_ID:kotlin.String) The subscription ID of the SIM the record is from.                                                                                                                                                                                                                                                                                                                |

|                                                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#) | [getContentUri](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getContentUri(kotlin.Int,%20kotlin.Int))`(`subscriptionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `efType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the content Uri for the specified elementary file on the specified SIM.                                                                                                                                                                                                                              |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)  | [getEncodedNameLength](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String))`(`resolver:` `[ContentResolver](https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#)`, `name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Returns the number of bytes required to encode the specified name when it is stored on the SIM.                                                                                                                                             |
| static[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#) | [getItemUri](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getItemUri(kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`subscriptionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `efType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `recordNumber:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Content Uri for the specific SIM record with the provided[RECORD_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER:kotlin.String). |

## Constants

### CONTENT_ITEM_TYPE

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

```
static val CONTENT_ITEM_TYPE: String
```

The MIME type of a CONTENT_URI subdirectory of a single SIM record.  

    Value: "vnd.android.cursor.item/sim-contact_v2"

### CONTENT_TYPE

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

```
static val CONTENT_TYPE: String
```

The MIME type of CONTENT_URI providing a directory of SIM records.  

    Value: "vnd.android.cursor.dir/sim-contact_v2"

### ELEMENTARY_FILE_TYPE

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

```
static val ELEMENTARY_FILE_TYPE: String
```

The type of the elementary file the record is from.  

    Value: "elementary_file_type"

**See Also**

- [android.provider.SimPhonebookContract.ElementaryFiles#EF_ADN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN:kotlin.Int)
- [android.provider.SimPhonebookContract.ElementaryFiles#EF_FDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN:kotlin.Int)
- [android.provider.SimPhonebookContract.ElementaryFiles#EF_SDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN:kotlin.Int)  

### ERROR_NAME_UNSUPPORTED

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

```
static val ERROR_NAME_UNSUPPORTED: Int
```

Value returned from[getEncodedNameLength(android.content.ContentResolver,java.lang.String)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String))when the name length could not be determined because the name could not be encoded.  

    Value: -1

### NAME

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

```
static val NAME: String
```

The name for this record.

An[IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#)will be thrown by insert and update if this exceeds the maximum supported length. Use[getEncodedNameLength(android.content.ContentResolver,java.lang.String)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String))to check how long the name will be after encoding.  

    Value: "name"

**See Also**

- [android.provider.SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH:kotlin.String)
- [#getEncodedNameLength(ContentResolver, String)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20kotlin.String))  

### PHONE_NUMBER

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

```
static val PHONE_NUMBER: String
```

The phone number for this record.

Only dialable characters are supported.

An[IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#)will be thrown by insert and update if this exceeds the maximum supported length or contains unsupported characters.  

    Value: "phone_number"

**See Also**

- [android.provider.SimPhonebookContract.ElementaryFiles#PHONE_NUMBER_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#PHONE_NUMBER_MAX_LENGTH:kotlin.String)
- [android.telephony.PhoneNumberUtils#isDialable(char)](https://developer.android.com/reference/kotlin/android/telephony/PhoneNumberUtils.html#isDialable(kotlin.Char))  

### RECORD_NUMBER

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

```
static val RECORD_NUMBER: String
```

The 1-based offset of the record in the elementary file that contains it.

This can be used to access individual SIM records by appending it to the elementary file URIs but it is not like a normal database ID because it is not auto-incrementing and it is not unique across SIM cards or elementary files. Hence, care should be taken when using it to ensure that it is applied to the correct SIM and EF.  

    Value: "record_number"

**See Also**

- [#getItemUri(int, int, int)](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#getItemUri(kotlin.Int,%20kotlin.Int,%20kotlin.Int))  

### SUBSCRIPTION_ID

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

```
static val SUBSCRIPTION_ID: String
```

The subscription ID of the SIM the record is from.  

    Value: "subscription_id"

**See Also**

- [android.telephony.SubscriptionInfo#getSubscriptionId()](https://developer.android.com/reference/kotlin/android/telephony/SubscriptionInfo.html#getSubscriptionId())

## Public methods

### getContentUri

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

```
static fun getContentUri(
    subscriptionId: Int, 
    efType: Int
): Uri
```

Returns the content Uri for the specified elementary file on the specified SIM.

When queried this Uri will return all of the contact records in the specified elementary file on the specified SIM. The available subscriptionIds and efTypes can be discovered by querying[ElementaryFiles.CONTENT_URI](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#CONTENT_URI:android.net.Uri).

If a SIM with the provided subscription ID does not exist or the SIM with the provided subscription ID doesn't support the specified entity file then all operations will throw an[IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#).

|                                                                                                                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `subscriptionId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the subscriptionId of the SIM card that this Uri will reference                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `efType`         | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the elementary file on the SIM that this Uri will reference Value is[android.provider.SimPhonebookContract.ElementaryFiles#EF_UNKNOWN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_UNKNOWN:kotlin.Int),[android.provider.SimPhonebookContract.ElementaryFiles#EF_ADN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN:kotlin.Int),[android.provider.SimPhonebookContract.ElementaryFiles#EF_FDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN:kotlin.Int), or[android.provider.SimPhonebookContract.ElementaryFiles#EF_SDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN:kotlin.Int) |

|                                                  Return                                                  ||
|-----------------------------------------------------------------------------|-----------------------------|
| [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#) | This value cannot be`null`. |

**See Also**

- [android.provider.SimPhonebookContract.ElementaryFiles#EF_ADN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN:kotlin.Int)
- [android.provider.SimPhonebookContract.ElementaryFiles#EF_FDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN:kotlin.Int)
- [android.provider.SimPhonebookContract.ElementaryFiles#EF_SDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN:kotlin.Int)  

### getEncodedNameLength

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

```
static fun getEncodedNameLength(
    resolver: ContentResolver, 
    name: String
): Int
```

Returns the number of bytes required to encode the specified name when it is stored on the SIM.

[ElementaryFiles.NAME_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH:kotlin.String)is specified in bytes but the encoded name may require more than 1 byte per character depending on the characters it contains. So this method can be used to check whether a name exceeds the max length.  
This method may take several seconds to complete, so it should only be called from a worker thread.

|                                                                   Parameters                                                                    ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `resolver` | [ContentResolver](https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#):This value cannot be`null`. |
| `name`     | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`.                        |

|                                                                                                                                                                      Return                                                                                                                                                                       ||
|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the number of bytes required by the encoded name or[ERROR_NAME_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#ERROR_NAME_UNSUPPORTED:kotlin.Int)if the name could not be encoded. Value is 0 or greater |

|                                   Exceptions                                   ||
|-----------------------------------|---------------------------------------------|
| `java.lang.IllegalStateException` | if the provider fails to return the length. |

**See Also**

- [android.provider.SimPhonebookContract.SimRecords#NAME](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#NAME:kotlin.String)
- [android.provider.SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH:kotlin.String)  

### getItemUri

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

```
static fun getItemUri(
    subscriptionId: Int, 
    efType: Int, 
    recordNumber: Int
): Uri
```

Content Uri for the specific SIM record with the provided[RECORD_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER:kotlin.String).

When queried this will return the record identified by the provided arguments.

For a non-existent record:

- query will return an empty cursor
- update will return 0
- delete will return 0

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `subscriptionId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the subscription ID of the SIM containing the record. If no SIM with this subscription ID exists then it will be treated as a non-existent record                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `efType`         | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the elementary file type containing the record. If the specified SIM doesn't support this elementary file then it will be treated as a non-existent record. Value is[android.provider.SimPhonebookContract.ElementaryFiles#EF_UNKNOWN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_UNKNOWN:kotlin.Int),[android.provider.SimPhonebookContract.ElementaryFiles#EF_ADN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN:kotlin.Int),[android.provider.SimPhonebookContract.ElementaryFiles#EF_FDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN:kotlin.Int), or[android.provider.SimPhonebookContract.ElementaryFiles#EF_SDN](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN:kotlin.Int) |
| `recordNumber`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the record number of the record this Uri should reference. This must be greater than 0. If there is no record with this record number in the specified entity file then it will be treated as a non-existent record. Value is 1 or greater                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

|                                                  Return                                                  ||
|-----------------------------------------------------------------------------|-----------------------------|
| [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#) | This value cannot be`null`. |

**See Also**

- [android.provider.SimPhonebookContract.ElementaryFiles#SUBSCRIPTION_ID](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#SUBSCRIPTION_ID:kotlin.String)
- [android.provider.SimPhonebookContract.ElementaryFiles#EF_TYPE](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.ElementaryFiles#EF_TYPE:kotlin.String)
- [#RECORD_NUMBER](https://developer.android.com/reference/kotlin/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER:kotlin.String)