Android Reference
libSQL Android Reference
This is currently in technical preview. Join us in Discord to report any issues.
This will only work with the Android Gradle Plugin for now. Fully Kotlin support is coming.
Installing
Add libsql as a implementation dependency in Gradle:
In-Memory Databases
libSQL supports connecting to in-memory databases for cases where you don’t require persistence:
Local Development
You can work locally using an SQLite file:
Embedded Replicas
You can work with embedded replicas that can sync from the remote URL and delegate writes to the remote primary database:
Manual Sync
The sync
function allows you to sync manually the local database with the
remote counterpart:
Simple query
You can pass a string to query()
to invoke a SQL statement, as well as
optional arguments:
Placeholders
libSQL supports the use of positional and named placeholders within SQL statements:
Batch Transactions
A batch consists of multiple SQL statements executed sequentially within an implicit transaction. The backend handles the transaction: success commits all changes, while any failure results in a full rollback with no modifications.
Transactions
Interactive transactions in SQLite ensure the consistency of a series of read and write operations within a transaction’s scope. These transactions give you control over when to commit or roll back changes, isolating them from other client activity.
Was this page helpful?