Added in API level 8

BackupDataInputStream


open class BackupDataInputStream : InputStream
kotlin.Any
   ↳ java.io.InputStream
   ↳ android.app.backup.BackupDataInputStream

Provides an java.io.InputStream-like interface for accessing an entity's data during a restore operation. Used by BackupHelper classes within the BackupAgentHelper mechanism.

When BackupHelper.restoreEntity() is called, the current entity's header has already been read from the underlying BackupDataInput. The entity's key string and total data size are available through this class's getKey() and size() methods, respectively.

Note: The caller should take care not to seek or close the underlying data source, nor read more than size() bytes from the stream.

Summary

Public methods
open String!

Report the key string associated with this entity within the backup data set.

open Int

Read one byte of entity data from the stream, returning it as an integer value.

open Int
read(b: ByteArray!, offset: Int, size: Int)

Read up to size bytes of data into a byte array, beginning at position offset within the array.

open Int

Read enough entity data into a byte array to fill the array.

open Int

Report the total number of bytes of data available for the current entity.

Inherited functions

Public methods

getKey

Added in API level 8
open fun getKey(): String!

Report the key string associated with this entity within the backup data set.

Return
String! The key string for this entity, equivalent to calling BackupDataInput#getKey() on the underlying BackupDataInput.

read

Added in API level 8
open fun read(): Int

Read one byte of entity data from the stream, returning it as an integer value. If more than size() bytes of data are read from the stream, the output of this method is undefined.

Return
Int The byte read, or undefined if the end of the stream has been reached.
Exceptions
java.io.IOException if an I/O error occurs.

read

Added in API level 8
open fun read(
    b: ByteArray!,
    offset: Int,
    size: Int
): Int

Read up to size bytes of data into a byte array, beginning at position offset within the array.

Parameters
b ByteArray!: Byte array into which the data will be read
off the start offset in array b at which the data is written.
len the maximum number of bytes to read.
offset Int: The data will be stored in b beginning at this index within the array.
size Int: The number of bytes to read in this operation. If insufficient data exists within the entity to fulfill this request, only as much data will be read as is available.
Return
Int The number of bytes of data read, or zero if all of the entity's data has already been read.
Exceptions
java.io.IOException If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
java.lang.NullPointerException If b is null.
java.lang.IndexOutOfBoundsException If off is negative, len is negative, or len is greater than b.length - off

read

Added in API level 8
open fun read(b: ByteArray!): Int

Read enough entity data into a byte array to fill the array.

Parameters
b ByteArray!: Byte array to fill with data from the stream. If the stream does not have sufficient data to fill the array, then the contents of the remainder of the array will be undefined.
Return
Int The number of bytes of data read, or zero if all of the entity's data has already been read.
Exceptions
java.io.IOException If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
java.lang.NullPointerException if b is null.

size

Added in API level 8
open fun size(): Int

Report the total number of bytes of data available for the current entity.

Return
Int The number of data bytes available, equivalent to calling BackupDataInput#getDataSize() on the underlying BackupDataInput.