Skip to main content
The Native Datastore plugin enables developers to persist key-value data such as user preferences and app settings directly on the user’s device or in the cloud via the Median JavaScript Bridge. This plugin supports both App Storage and Cloud Storage, giving you flexibility in how data is saved and accessed across sessions and devices.

Why use native datastore

  • User preference persistence: Save settings like theme, language, and notification preferences that survive app restarts and WebView cache clears without relying on cookies.
  • Authentication state: Store session tokens and login flags locally so users stay authenticated between app launches, with cloud storage restoring state after a reinstall.
  • Cross-device settings sync: Use cloud storage to carry user preferences across devices without building a sync backend. When a user reinstalls or switches devices, their settings are restored automatically.
  • Offline-first apps: Cache lightweight values like a user’s account ID or last-known app state so the app can render meaningful content without a network connection.

Storage backends

App Storage is available offline and persists on the device until the app is updated, reinstalled, or the device is upgraded. Ideal for session-specific or device-bound preferences. Cloud Storage syncs data with the user’s cloud account, making it accessible across multiple devices and app re-installations. Use Cloud Storage for settings that need to follow the user across devices.

Storage limits

Android cloud storage uses BackupManager, which schedules sync operations asynchronously. A precise sync time cannot be guaranteed as the system triggers a backup at some point after your app requests one. See Google’s BackupManager documentation for details.

Implementation guide

App storage

This option utilizes Android’s SharedPreferences and iOS’s UserDefaults to store the local app settings on the user’s device. You will provide a key-value pair to save the app settings. You will then use the key to retrieve or delete the corresponding value. Note: On Android the location of the App Storage (SharedPreferences) database file is DATA/data/APP_PACKAGE_NAME/shared_prefs/user_preferences.xml

Set command (app storage)

To save a value, use the following JavaScript Bridge command. To get status of this write operation, define a callback function in JavaScript and pass as statuscallback (Optional).

Get command (app storage)

To retrieve the saved settings define a callback function and call the JavaScript Bridge command below, providing the KEY of the saved setting and the callback that was defined. The status of the read operation is included as a parameter in the result variable as shown below.

Delete command (app storage)

To delete a setting provide the KEY of the previously saved setting. The status of the delete operation can be accessed through the function passed as statuscallback (Optional).

Delete all (app storage)

Removes all stored key-value pairs from device-local storage.

Cloud storage

This option utilizes Android SharedPreferences combined with the native Android Backup Service and Apple Keychain Services to store the local app settings on a device. You will provide a key-value pair to save the app settings. You will use the key to retrieve or delete the settings. Note: On Android, the location of the Cloud Storage (SharedPreferences) database file is DATA/data/APP_PACKAGE_NAME/shared_prefs/user_preferences_backup.xml

Set command (cloud storage)

To save a value, use the following JavaScript Bridge command. To get status of this write operation, define a callback function in JavaScript (Optional).

Get command (cloud storage)

To retrieve the saved settings define a callback function and call the JavaScript Bridge command below, providing the KEY of the saved setting and the callback that was defined. The status of the read operation is included as a parameter in the result variable as shown below.
Learn more about using promises with the JavaScript Bridge.

Delete command (cloud storage)

To delete a setting provide the KEY of the previously saved setting. The status of the delete operation can be accessed through the function passed as statuscallback (Optional).

Delete all (cloud storage)

Delete all saved settings from the device:

Callback status reference

All write and delete operations return status via statuscallback; get returns status via callback. Check result.status in your callback to confirm success or handle errors.

Demo app

Try out the plugin on iOS and Android with our interactive demo apps.

Frequently asked questions

Ensure the JavaScript Bridge is enabled in App Studio and that your page has fully loaded before calling JavaScript Bridge functions. Verify that the plugin is enabled in your app configuration.
Confirm that the key used in get exactly matches the key used in set. Keys are case-sensitive. Also verify that the value was successfully stored by checking the status returned to your statuscallback.
On Android, BackupManager schedules sync operations asynchronously and the timing is system-determined and cannot be forced. On iOS, Keychain sync depends on the user’s iCloud Keychain settings. Verify that iCloud Keychain is enabled on both devices.
Last modified on December 3, 2026