Offline Storage
Ionic Offline Storage is a cross-platform data storage system that works on iOS and Android. Powered by SQLite, a SQL database engine for building powerful, data-driven apps entirely in JavaScript.
This solution makes it easy to add offline storage to Ionic apps that are secure (encrypted on device using 256-bit AES), highly performant, and provide advanced data querying. Learn more.
#
InstallationIf you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
- Capacitor
- Cordova
#
Getting StartedOffline Storage is powered by SQLite, so it's incredibly easy to use - simply leverage familiar SQL query syntax.
If using Angular, start by injecting Offline Storage as a provider to the project in app.module.ts
:
Next, import @ionic-enterprise/offline-storage
into the desired class (A dedicated service that encapsulates Offline Storage logic is recommended).
Next, initialize the database then immediately create (or open) a table:
#
Basic QueriesInsert data into a database table:
Read data from a database table:
Update data:
Delete data:
Close the database:
Delete the database (provide the same configuration details used when creating it):
#
Transactions#
Single-statement Transactions#
Batch Transactions#
Test FunctionsUseful for debugging issues.