# PreviewProgram

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/tvprovider/media/tv/PreviewProgram "View this page in Java")

<br />

```
class PreviewProgram
```

<br />

*** ** * ** ***

A convenience class to access[PreviewPrograms](https://developer.android.com/reference/kotlin/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[TvContractCompat](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/TvContractCompat).

Usage example when inserting a preview program:  

```kotlin
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:  

```kotlin
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:  

```kotlin
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:  

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

## Summary

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

|                                                                                  ### Constants                                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>` | [PROJECTION](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#PROJECTION()) The projection for a[PreviewProgram](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram)query. |

|                                                     ### Public functions                                                      |
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                           | [equals](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#equals(java.lang.Object))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`!)`                                                                                                                                                                                                                              |
| `java-static `[PreviewProgram](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram)`!` | [fromCursor](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#fromCursor(android.database.Cursor))`(cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Creates a Program object from a cursor including the fields defined in[PreviewPrograms](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms).    |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                 | [getChannelId](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#getChannelId())`()`                                                                                                                                                                                                                                                                                                                       |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                   | [getWeight](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#getWeight())`()`                                                                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                           | [hasAnyUpdatedValues](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#hasAnyUpdatedValues(androidx.tvprovider.media.tv.PreviewProgram))`(update: `[PreviewProgram](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram)`!)` Indicates whether some other PreviewProgram has any set attribute that is different from this PreviewProgram's respective attributes. |
| [ContentValues](https://developer.android.com/reference/android/content/ContentValues.html)`!`                                | [toContentValues](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#toContentValues())`()`                                                                                                                                                                                                                                                                                                                 |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`                                          | [toString](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/PreviewProgram#toString())`()`                                                                                                                                                                                                                                                                                                                               |

## Constants

### PROJECTION

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

```
const val PROJECTION: Array<String!>
```

The projection for a[PreviewProgram](https://developer.android.com/reference/kotlin/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 functions

### equals

```
fun equals(other: Any!): Boolean
```  

### fromCursor

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

```
java-static fun fromCursor(cursor: Cursor!): PreviewProgram!
```

Creates a Program object from a cursor including the fields defined in[PreviewPrograms](https://developer.android.com/reference/kotlin/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms).  

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

|                                                     Returns                                                     |
|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [PreviewProgram](https://developer.android.com/reference/kotlin/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)  

```
fun getChannelId(): Long
```  

|                                    Returns                                    |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The value of[COLUMN_CHANNEL_ID](https://developer.android.com/reference/kotlin/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)  

```
fun getWeight(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The value of[COLUMN_WEIGHT](https://developer.android.com/reference/kotlin/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)  

```
fun hasAnyUpdatedValues(update: PreviewProgram!): Boolean
```

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)  

```
fun toContentValues(): ContentValues!
```  

|                                            Returns                                             |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [ContentValues](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

```
fun toString(): String!
```