SQLiteStorage
Base implementation for SQLite storage that uses SQLCipher for encrypted storage. This class provides a secure storage solution with a generic approach for different data types. It supports multiple tables through a table registration mechanism.
This is an abstract base class that provides common SQLite database functionality. Subclasses should implement their specific storage operations based on their table structure.
Parameters
Configuration object containing all database settings. See SQLiteStorageConfig for details.
Types
Helper class for creating and managing the SQLite database. This class extends SQLiteOpenHelper which is required for proper SQLite database management in Android. It provides hooks for database creation and version upgrades, but delegates the actual table creation to the registered table creator functions.
Properties
Functions
Attempt to restore the database from the most recent backup.
Begin a database transaction.
Check if the database is open and throw an exception if it's not. This provides a more informative error message than the default UninitializedPropertyAccessException.
Remove old backup files exceeding the configured maximum backup count.
Close the database connection.
Create a backup of the current database file. The backup file will be encrypted with the same passphrase as the original database.
Factory method to create the appropriate database helper. This method follows the factory method pattern to allow subclasses to provide their own DatabaseHelper implementation without modifying the base class.
End the current transaction.
Execute a database operation on the IO dispatcher. This is a helper method for subclasses to use when implementing their own database operations.
Execute SQL with the given arguments. This is a convenience method for executing SQL statements.
Generate a backup filename with timestamp. Format: {databaseName}backup{timestamp}.db
Initialize the SQL database storage. This method creates the database and tables if they don't exist. If the database cannot be opened, it will attempt to restore from backup if available.
List all backup files for the current database, sorted by timestamp (newest first).
Parse the timestamp from a backup filename.
Register a table creator function that will be called when the database is created. This allows multiple tables to be created in the same database.
Mark the current transaction as successful.