public class LocalStorage


An AppSearch storage system which stores data locally in the app's storage space using a bundled version of the search native library.

The search native library is an on-device searching library that allows apps to define androidx.appsearch.app.AppSearchSchemas, save and query a variety of Documents. The library needs to be initialized before using, which will create a folder to save data in the app's storage space.

Queries are executed multi-threaded, but a single thread is used for mutate requests (put, delete, etc..).

Summary

Nested types

Contains information relevant to creating a global search session.

Builder for GlobalSearchContext objects.

public final class LocalStorage.SearchContext

Contains information about how to create the search session.

Builder for SearchContext objects.

Public methods

createGlobalSearchSessionAsync

Added in 1.1.0-alpha06
public static @NonNull ListenableFuture<GlobalSearchSessioncreateGlobalSearchSessionAsync(
    @NonNull LocalStorage.GlobalSearchContext context
)

Opens a new GlobalSearchSession on this storage.

The GlobalSearchSession opened from this LocalStorage allows the user to search across all local databases within the LocalStorage of this app, however cross-app search is not possible with LocalStorage.

This process requires a native search library. If it's not created, the initialization process will create one.

createSearchSessionAsync

Added in 1.1.0-alpha06
public static @NonNull ListenableFuture<AppSearchSessioncreateSearchSessionAsync(@NonNull LocalStorage.SearchContext context)

Opens a new AppSearchSession on this storage with executor.

This process requires a native search library. If it's not created, the initialization process will create one.

Parameters
@NonNull LocalStorage.SearchContext context

The SearchContext contains all information to create a new AppSearchSession