# AppSearchResult

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

*** ** * ** ***


```
public final class AppSearchResult<ValueType>
```

<br />

*** ** * ** ***

Information about the success or failure of an AppSearch call.

| Parameters |
|---|---|
| `<ValueType>` | The type of result object for successful calls. |

## Summary

| ### Constants |
|---|---|
| `static final int` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_ABORTED() = 13` The operation is aborted because an internal state change invalidated the results of the request. |
| `static final int` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_ALREADY_EXISTS() = 12` The operation is invalid because the resource already exists and can't be replaced. |
| `static final int` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_DENIED() = 9` The requested operation is denied for the caller. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_INTERNAL_ERROR() = 2` An internal error occurred within AppSearch, which the caller cannot address. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_INVALID_ARGUMENT() = 3` The caller supplied invalid arguments to the call. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_INVALID_SCHEMA() = 7` The caller supplied a schema which is invalid or incompatible with the previous schema. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_IO_ERROR() = 4` An issue occurred reading or writing to storage. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_NOT_FOUND() = 6` An entity the caller requested to interact with does not exist in the system. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_OK() = 0` The call was successful. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_OUT_OF_SPACE() = 5` Storage is out of space, and no more space could be reclaimed. |
| `static final int` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_RATE_LIMITED() = 10` The caller has hit AppSearch's rate limit and the requested operation has been rejected. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_SECURITY_ERROR() = 8` The caller requested an operation it does not have privileges for. |
| `static final int` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_UNAVAILABLE() = 14` An error occurred due to AppSearch not having the necessary resources to execute the API call. |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_UNKNOWN_ERROR() = 1` An unknown error occurred while processing the call. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getErrorMessage()()` Returns the error message associated with this result. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()()` Returns one of the `RESULT` constants defined in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable ValueType` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultValue()()` Returns the result value associated with this result, if it was successful. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#isSuccess()()` Returns `true` if `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()` equals `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_OK()`. |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType>` | `<ValueType> https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#newFailedResult(int,java.lang.String)(int resultCode, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html errorMessage)` Creates a new failed `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`. |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType>` | `<ValueType> https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#newSuccessfulResult(ValueType)(@https://developer.android.com/reference/androidx/annotation/Nullable ValueType value)` Creates a new successful `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`. |
| `@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/AppSearchResult#toString()()` |

## Constants

### RESULT_ABORTED

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

```
@ExperimentalAppSearchApi
public static final int RESULT_ABORTED = 13
```

The operation is aborted because an internal state change invalidated the results of the request. New requests should be able to process correctly and callers may, therefore, wish to retry.

Note: if retrying, the caller should restart the request at the topmost API level. For example, if `https://developer.android.com/reference/androidx/appsearch/app/SearchResults#getNextPageAsync()` throws an exception with code `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_ABORTED()`, then the caller should restart the search via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` API with a new `https://developer.android.com/reference/androidx/appsearch/app/SearchResults` object, instead of calling `https://developer.android.com/reference/androidx/appsearch/app/SearchResults#getNextPageAsync()` again with the original `https://developer.android.com/reference/androidx/appsearch/app/SearchResults` object.

### RESULT_ALREADY_EXISTS

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

```
@ExperimentalAppSearchApi
public static final int RESULT_ALREADY_EXISTS = 12
```

The operation is invalid because the resource already exists and can't be replaced.

### RESULT_DENIED

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

```
@ExperimentalAppSearchApi
public static final int RESULT_DENIED = 9
```

The requested operation is denied for the caller. This error is logged and returned for denylist rejections.

### RESULT_INTERNAL_ERROR

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

```
public static final int RESULT_INTERNAL_ERROR = 2
```

An internal error occurred within AppSearch, which the caller cannot address. This error may be considered similar to `https://developer.android.com/reference/java/lang/IllegalStateException.html`

### RESULT_INVALID_ARGUMENT

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

```
public static final int RESULT_INVALID_ARGUMENT = 3
```

The caller supplied invalid arguments to the call. This error may be considered similar to `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.

### RESULT_INVALID_SCHEMA

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

```
public static final int RESULT_INVALID_SCHEMA = 7
```

The caller supplied a schema which is invalid or incompatible with the previous schema.

### RESULT_IO_ERROR

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

```
public static final int RESULT_IO_ERROR = 4
```

An issue occurred reading or writing to storage. The call might succeed if repeated. This error may be considered similar to `https://developer.android.com/reference/java/io/IOException.html`.

### RESULT_NOT_FOUND

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

```
public static final int RESULT_NOT_FOUND = 6
```

An entity the caller requested to interact with does not exist in the system.

### RESULT_OK

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

```
public static final int RESULT_OK = 0
```

The call was successful.

### RESULT_OUT_OF_SPACE

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

```
public static final int RESULT_OUT_OF_SPACE = 5
```

Storage is out of space, and no more space could be reclaimed.

### RESULT_RATE_LIMITED

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

```
@ExperimentalAppSearchApi
public static final int RESULT_RATE_LIMITED = 10
```

The caller has hit AppSearch's rate limit and the requested operation has been rejected. The caller is recommended to reschedule tasks with exponential backoff.

### RESULT_SECURITY_ERROR

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

```
public static final int RESULT_SECURITY_ERROR = 8
```

The caller requested an operation it does not have privileges for.

### RESULT_UNAVAILABLE

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

```
@ExperimentalAppSearchApi
public static final int RESULT_UNAVAILABLE = 14
```

An error occurred due to AppSearch not having the necessary resources to execute the API call.

### RESULT_UNKNOWN_ERROR

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

```
public static final int RESULT_UNKNOWN_ERROR = 1
```

An unknown error occurred while processing the call.

## Public methods

### equals

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

### getErrorMessage

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

```
public @Nullable String getErrorMessage()
```

Returns the error message associated with this result.

If `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#isSuccess()` is `true`, the error message is always `null`. The error message may be `null` even if `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#isSuccess()` is `false`. See the documentation of the particular `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession` call producing this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for what is returned by `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getErrorMessage()`.

### getResultCode

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

```
public int getResultCode()
```

Returns one of the `RESULT` constants defined in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`.

### getResultValue

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

```
public @Nullable ValueType getResultValue()
```

Returns the result value associated with this result, if it was successful.

See the documentation of the particular `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession` call producing this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for what is placed in the result value by that call.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` is not successful. |

### hashCode

```
public int hashCode()
```

### isSuccess

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

```
public boolean isSuccess()
```

Returns `true` if `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()` equals `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_OK()`.

### newFailedResult

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

```
public static @NonNull AppSearchResult<ValueType> <ValueType> newFailedResult(int resultCode, @Nullable String errorMessage)
```

Creates a new failed `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`.

| Parameters |
|---|---|
| `int resultCode` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html errorMessage` | An optional string describing the reason or nature of the failure. |

### newSuccessfulResult

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

```
public static @NonNull AppSearchResult<ValueType> <ValueType> newSuccessfulResult(@Nullable ValueType value)
```

Creates a new successful `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable ValueType value` | An optional value to associate with the successful result of the operation being performed. |

### toString

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