Program
public final class Program implements Comparable
A convenience class to access 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 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 Program.BuilderThis Builder class simplifies the creation of a |
Public methods |
|
|---|---|
int |
|
boolean |
|
static Program |
fromCursor(Cursor cursor)Creates a Program object from a cursor including the fields defined in |
String[] |
|
long |
|
long |
|
int |
Returns the value of |
@Nullable String |
Returns the value of |
long |
|
int |
hashCode() |
boolean |
|
ContentValues |
|
String |
toString() |
Public methods
compareTo
public int compareTo(@NonNull Program other)
| Returns | |
|---|---|
int |
The chronological order of the programs. |
fromCursor
public static Program fromCursor(Cursor cursor)
Creates a Program object from a cursor including the fields defined in Programs.
| Parameters | |
|---|---|
Cursor cursor |
A row from the TV Input Framework database. |
| Returns | |
|---|---|
Program |
A Program with the values taken from the cursor. |
getBroadcastGenres
public String[] getBroadcastGenres()
| Returns | |
|---|---|
String[] |
The value of |
getChannelId
public long getChannelId()
| Returns | |
|---|---|
long |
The value of |
getEndTimeUtcMillis
public long getEndTimeUtcMillis()
| Returns | |
|---|---|
long |
The value of |
getEventId
public int getEventId()
Returns the value of COLUMN_EVENT_ID for the program.
No-op on devices prior to R.
getGlobalContentId
public @Nullable String getGlobalContentId()
Returns the value of COLUMN_GLOBAL_CONTENT_ID for the program.
No-op on devices prior to R.
getStartTimeUtcMillis
public long getStartTimeUtcMillis()
| Returns | |
|---|---|
long |
The value of |
isRecordingProhibited
public boolean isRecordingProhibited()
| Returns | |
|---|---|
boolean |
The value of |
toContentValues
public ContentValues toContentValues()
| Returns | |
|---|---|
ContentValues |
The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database. |