# AppSearchBlobHandle

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

*** ** * ** ***


```
public final class AppSearchBlobHandle
```

<br />

*** ** * ** ***

An identifier to represent a blob in AppSearch.

A "blob" is a large binary object. It is used to store a significant amount of data that is not searchable, such as images, videos, audio files, or other binary data. Unlike other fields in AppSearch, blobs are stored as blob files on disk rather than in memory, and use `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` to read and write. This allows for efficient handling of large, non-searchable content.

`https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` is a light-weight `Property` of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`, which is a pointer to the heavy-weight blob data.

The blob data could be written via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#openBlobForWriteAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)` and read via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#openBlobForReadAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`.

A `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` with `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle``Property` could be put and read without the large blob data. This offers lazy retrieval to blob data when searching `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` in AppSearch.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)` |   |

## Summary

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#createWithSha256(byte[],java.lang.String,java.lang.String,java.lang.String)( @https://developer.android.com/reference/androidx/annotation/NonNull byte[] digest, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html databaseName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html namespace )` Create a new AppSearch blob identifier with given digest, package, database and namespace. |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o)` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#getDatabaseName()()` Returns the name of database stored the blob that this object is representing. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#getNamespace()()` Returns the app-defined namespace this blob resides in. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#getPackageName()()` Returns the package name indicating the owner app of the blob that this object is representing. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[]` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#getSha256Digest()()` Returns the SHA-256 hash of the blob that this object is representing. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle#toString()()` |

## Public methods

### createWithSha256

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

```
public static @NonNull AppSearchBlobHandle createWithSha256(
    @NonNull byte[] digest,
    @NonNull String packageName,
    @NonNull String databaseName,
    @NonNull String namespace
)
```

Create a new AppSearch blob identifier with given digest, package, database and namespace.

The package name and database name indicated where this blob will be stored. To write, commit or read this blob via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession`, it must match the package name and database name of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession`.

For two objects of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to be considered equal, the `packageName`, `database`, `namespace` and `digest` must be equal.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[] digest` | The SHA-256 hash of the blob this is representing. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName` | The package name of the owner of this Blob. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html databaseName` | The database name of this blob to stored into. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html namespace` | The namespace of this blob resides in. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` | a new instance of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` object. |

### equals

```
public boolean equals(@Nullable Object o)
```

### getDatabaseName

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

```
public @NonNull String getDatabaseName()
```

Returns the name of database stored the blob that this object is representing.

For two objects of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to be considered equal, the `packageName`, `database`, `namespace` and `digest` must be equal.

### getNamespace

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

```
public @NonNull String getNamespace()
```

Returns the app-defined namespace this blob resides in.

For two objects of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to be considered equal, the `packageName`, `database`, `namespace` and `digest` must be equal.

### getPackageName

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

```
public @NonNull String getPackageName()
```

Returns the package name indicating the owner app of the blob that this object is representing.

For two objects of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to be considered equal, the `packageName`, `database`, `namespace` and `digest` must be equal.

### getSha256Digest

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

```
public @NonNull byte[] getSha256Digest()
```

Returns the SHA-256 hash of the blob that this object is representing.

For two objects of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to be considered equal, the `packageName`, `database`, `namespace` and `digest` must be equal.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```