# PreviewProgram

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/PreviewProgram.java+class:androidx.tvprovider.media.tv.PreviewProgram) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/tvprovider#1.1.0)

*** ** * ** ***


```
public final class PreviewProgram
```

<br />

*** ** * ** ***

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

This class makes it easy to insert or retrieve a preview 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 preview program:

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

Usage example when retrieving a preview program:

```
PreviewProgram previewProgram;
try (Cursor cursor = resolver.query(previewProgramUri, null, null, null, null)) {
    if (cursor != null && cursor.getCount() != 0) {
        cursor.moveToNext();
        previewProgram = PreviewProgram.fromCursor(cursor);
    }
}
```

Usage example when updating an existing preview program:

```
PreviewProgram updatedProgram = new PreviewProgram.Builder(previewProgram)
        .setWeight(20)
        .build();
getContentResolver().update(TvContractCompat.buildPreviewProgramUri(updatedProgram.getId()),
        updatedProgram.toContentValues(), null, null);
```

Usage example when deleting a preview program:

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

## Summary

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

| ### Constants |
|---|---|
| `static final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html String[]` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#PROJECTION()` The projection for a `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram` query. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#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.PreviewPrograms`. |
| `long` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#getChannelId()()` |
| `int` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#getWeight()()` |
| `boolean` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#hasAnyUpdatedValues(androidx.tvprovider.media.tv.PreviewProgram)(https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram update)` Indicates whether some other PreviewProgram has any set attribute that is different from this PreviewProgram's respective attributes. |
| `https://developer.android.com/reference/android/content/ContentValues.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#toContentValues()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram#toString()()` |

## Constants

### PROJECTION

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

```
public static final @NonNull String[] PROJECTION
```

The projection for a `https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram` query.

This provides a array of strings containing the columns to be used in the query and in creating a Cursor object, which is used to iterate through the rows in the table.

## Public methods

### 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 PreviewProgram 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.PreviewPrograms`.

| 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/PreviewProgram` | A Program with the values taken from the cursor. |

### 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.PreviewPrograms#COLUMN_CHANNEL_ID()` for the program. |

### getWeight

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

```
public int getWeight()
```

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

### hasAnyUpdatedValues

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

```
public boolean hasAnyUpdatedValues(PreviewProgram update)
```

Indicates whether some other PreviewProgram has any set attribute that is different from this PreviewProgram's respective attributes. An attribute is considered "set" if its key is present in the ContentValues vector.

### 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()
```