SQLDatabase
The use of ThreadLocal underpins SQLDatabase's thread-safety.
A thread can acquire at most one connection session per database instance. Sessions hold at most one connection at any given time, and exclusively. Sessions control all access to a database's connections and each session is thread-bound. This prevents two threads from ever sharing a single connection.
This is the same strategy Google employs in the Android SDK.
See also
Constructors
Properties
Functions
Inserts rowid-table rows and writes their BLOB values incrementally with bounded memory.
Cancellable counterpart of insertBlobs.
Opens an explicitly owned session with callbacks for coordinating its lifecycle with an external owner. The returned session is not thread-safe and must be closed when no longer needed.
Executes a cancellable query. If the cancellationSignal is cancelled from another thread, the query will be aborted at the earliest opportunity and an OperationCancelledException will be thrown.
Returns a forward-only streaming ICursor backed by a ForwardCursor. The caller must close the returned cursor to release the underlying prepared statement back to the connection's cache and to release the session's connection back to the pool.
Cancellable counterpart of queryForwardOnly.
Executes a cancellable query while stepping no more than maximumRows.
Registers a progress handler that is invoked periodically during long-running SQL statements on all database connections managed by this database. If the handler returns non-zero, the operation is interrupted.