Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#constants) \| [Methods](https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#inhmethods)

# SimPhonebookContract.SimRecords

*** ** * ** ***


`
public
static
final

class
SimPhonebookContract.SimRecords
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.SimPhonebookContract.SimRecords |

<br />

*** ** * ** ***

Constants for the contact records on a SIM card.

### Data


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 `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#CONTENT_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 `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#MAX_RECORDS` column.


The `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#PHONE_NUMBER` column can only contain dialable characters and this
applies regardless of the SIM that is being used. See
`https://developer.android.com/reference/android/telephony/PhoneNumberUtils#isDialable(char)` for more details. Additionally
the phone number can contain at most `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#PHONE_NUMBER_MAX_LENGTH`
characters. The `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#NAME` column can contain at most
`https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH` 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
`https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#getEncodedNameLength(android.content.ContentResolver,%20java.lang.String)`.

### Operations

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

<br />

## Summary

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

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

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### CONTENT_ITEM_TYPE

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

```
public static final String CONTENT_ITEM_TYPE
```

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

<br />

Constant 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#ApiLevels)

```
public static final String CONTENT_TYPE
```

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

<br />

Constant 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#ApiLevels)

```
public static final String ELEMENTARY_FILE_TYPE
```

The type of the elementary file the record is from.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN`

Constant Value:

"elementary_file_type"


### ERROR_NAME_UNSUPPORTED

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

```
public static final int ERROR_NAME_UNSUPPORTED
```

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

<br />

Constant Value:

-1
(0xffffffff)


### NAME

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

```
public static final String NAME
```

The name for this record.

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

<br />

**See also:**

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

Constant Value:

"name"


### PHONE_NUMBER

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

```
public static final String PHONE_NUMBER
```

The phone number for this record.

Only dialable characters are supported.

An `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown by insert and update if this
exceeds the maximum supported length or contains unsupported characters.

<br />

**See also:**

- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#PHONE_NUMBER_MAX_LENGTH`
- `https://developer.android.com/reference/android/telephony/PhoneNumberUtils#isDialable(char)`

Constant Value:

"phone_number"


### RECORD_NUMBER

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

```
public static final String RECORD_NUMBER
```

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.

<br />

**See also:**

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

Constant Value:

"record_number"


### SUBSCRIPTION_ID

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

```
public static final String SUBSCRIPTION_ID
```

The subscription ID of the SIM the record is from.

<br />

**See also:**

- `https://developer.android.com/reference/android/telephony/SubscriptionInfo#getSubscriptionId()`

Constant Value:

"subscription_id"


## Public methods

### getContentUri

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

```
public static Uri getContentUri (int subscriptionId, 
                int efType)
```

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 `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#CONTENT_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 `https://developer.android.com/reference/java/lang/IllegalArgumentException`.

<br />

| Parameters ||
|---|---|
| `subscriptionId` | `int`: the subscriptionId of the SIM card that this Uri will reference <br /> |
| `efType` | `int`: the elementary file on the SIM that this Uri will reference. Value is one of the following: - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_UNKNOWN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN`

### getEncodedNameLength

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

```
public static int getEncodedNameLength (ContentResolver resolver, 
                String name)
```

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

`https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH` 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.

<br />

| Parameters ||
|---|---|
| `resolver` | `ContentResolver`: This value cannot be `null`. <br /> |
| `name` | `String`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | the number of bytes required by the encoded name or `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#ERROR_NAME_UNSUPPORTED` if the name could not be encoded. Value is 0 or greater <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the provider fails to return the length. |

**See also:**

- `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#NAME`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#NAME_MAX_LENGTH`

### getItemUri

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

```
public static Uri getItemUri (int subscriptionId, 
                int efType, 
                int recordNumber)
```

Content Uri for the specific SIM record with the provided `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER`.

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

<br />

<br />

| Parameters ||
|---|---|
| `subscriptionId` | `int`: 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 <br /> |
| `efType` | `int`: 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 one of the following: - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_UNKNOWN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_ADN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_FDN` - `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_SDN` |
| `recordNumber` | `int`: 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 <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#SUBSCRIPTION_ID`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.ElementaryFiles#EF_TYPE`
- `https://developer.android.com/reference/android/provider/SimPhonebookContract.SimRecords#RECORD_NUMBER`