# Program

Artifact: [androidx.tvprovider:tvprovider](https://developer.android.com/jetpack/androidx/releases/tvprovider) [View Source](https://cs.android.com/search?q=file:androidx/tvprovider/media/tv/Program.java+class:androidx.tvprovider.media.tv.Program) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

*** ** * ** ***


```
public final class Program implements Comparable<Program>
```

<br />

*** ** * ** ***

A convenience class to access `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs` entries in the system content provider.

This class makes it easy to insert or retrieve a program from the system content provider, which is defined in `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat`.

Usage example when inserting a program:

```
Program program = new Program.Builder()
        .setChannelId(channel.getId())
        .setTitle("Program Title")
        .setDescription("Program Description")
        .setPosterArtUri(Uri.parse("http://example.com/poster_art.png"))
        // Set more attributes...
        .build();
Uri programUri = getContentResolver().insert(Programs.CONTENT_URI, program.toContentValues());
```

Usage example when retrieving a program:

```
Program program;
try (Cursor cursor = resolver.query(programUri, null, null, null, null)) {
    if (cursor != null && cursor.getCount() != 0) {
        cursor.moveToNext();
        program = Program.fromCursor(cursor);
    }
}
```

Usage example when updating an existing program:

```
Program updatedProgram = new Program.Builder(program)
        .setEndTimeUtcMillis(newProgramEndTime)
        .build();
getContentResolver().update(TvContractCompat.buildProgramUri(updatedProgram.getId()),
        updatedProgram.toContentValues(), null, null);
```

Usage example when deleting a program:

```
getContentResolver().delete(TvContractCompat.buildProgramUri(existingProgram.getId()),
        null, null);
```

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/tvprovider/media/tv/Program.Builder` This Builder class simplifies the creation of a `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program` object. |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#compareTo(androidx.tvprovider.media.tv.Program)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/tvprovider/media/tv/Program other)` |
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static https://developer.android.com/reference/androidx/tvprovider/media/tv/Program` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#fromCursor(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor.html cursor)` Creates a Program object from a cursor including the fields defined in `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs`. |
| `String[]` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getBroadcastGenres()()` |
| `long` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getChannelId()()` |
| `long` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getEndTimeUtcMillis()()` |
| `int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getEventId()()` Returns the value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_EVENT_ID()` for the program. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getGlobalContentId()()` Returns the value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_GLOBAL_CONTENT_ID()` for the program. |
| `long` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#getStartTimeUtcMillis()()` |
| `int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#isRecordingProhibited()()` |
| `https://developer.android.com/reference/android/content/ContentValues.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#toContentValues()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program#toString()()` |

## Public methods

### compareTo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public int compareTo(@NonNull Program other)
```

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/tvprovider/media/tv/Program other` | The program you're comparing to. |

| Returns |
|---|---|
| `int` | The chronological order of the programs. |

### equals

```
public boolean equals(Object other)
```

### fromCursor

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public static Program fromCursor(Cursor cursor)
```

Creates a Program object from a cursor including the fields defined in `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/database/Cursor.html cursor` | A row from the TV Input Framework database. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/tvprovider/media/tv/Program` | A Program with the values taken from the cursor. |

### getBroadcastGenres

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public String[] getBroadcastGenres()
```

| Returns |
|---|---|
| `String[]` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_BROADCAST_GENRE()` for the program. |

### getChannelId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public long getChannelId()
```

| Returns |
|---|---|
| `long` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_CHANNEL_ID()` for the program. |

### getEndTimeUtcMillis

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public long getEndTimeUtcMillis()
```

| Returns |
|---|---|
| `long` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_END_TIME_UTC_MILLIS()` for the program. |

### getEventId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public int getEventId()
```

Returns the value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_EVENT_ID()` for the program.

No-op on devices prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#R`.

### getGlobalContentId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public @Nullable String getGlobalContentId()
```

Returns the value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_GLOBAL_CONTENT_ID()` for the program.

No-op on devices prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#R`.

### getStartTimeUtcMillis

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public long getStartTimeUtcMillis()
```

| Returns |
|---|---|
| `long` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_START_TIME_UTC_MILLIS()` for the program. |

### hashCode

```
public int hashCode()
```

### isRecordingProhibited

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public boolean isRecordingProhibited()
```

| Returns |
|---|---|
| `boolean` | The value of `https://developer.android.com/reference/androidx/tvprovider/media/tv/TvContractCompat.Programs#COLUMN_RECORDING_PROHIBITED()` for the program. |

### toContentValues

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

```
public ContentValues toContentValues()
```

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/ContentValues.html` | The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database. |

### toString

```
public String toString()
```