Skip to main content

Secure Storage - Troubleshooting

General troubleshooting

To verify the plugin is correctly installed, there are some test methods available on the plugin:

// Verify that both the JavaScript and native part of this plugin
// are installed in your Ionic app
await this.sqlite.echoTest();

// Verify basic database access operations including opening a database
// Prints "OPEN database: OK"
await this.sqlite.selfTest();

Database location or iosDatabaseLocation setting is now mandatory in openDatabase call.

This message indicates that location or iosDatabaseLocation was not provided in the options for create or openDatabase, which is now required. A value of 'default' is appropriate for most use cases.

Unable to open database file

Symptom: create or openDatabase fails with a message indicating the engine was unable to open the database file or that the database file is not a valid database.

Diagnosis: The usual culprit here is that an unencrypted database was created first, and then a key was specified later (to enable encryption), but by then the original database already exists but can't be read since it's not encrypted.

Solution: The solution is to change the name of the database file whenever switching between a database used with and without encryption. Additionally, uninstalling the app will delete the database.

App is rejected for storing data in iCloud

The location option in create can be used to specify where the database file is stored on device. The value of default will store the database file in a non-iCloud backed up location. This is recommended for most apps, though iCloud backup could be legitimate for some use cases but that is app-specific.