System Methods

System Methods

Several methods are available for common computing use cases, like saving application variables, storing files or local database. These will be localized to the device and are not available across all instances of the application.


When an application requires a variable which should be user provided or will change between different instances, settings is a way to approach this problem.

Config Setup

You should have familiarity with Configuration Files before exploring further.

Add the settings: configuration to your app's config.yaml and specify each setting your app will save.

  apiKey: 'dfe972dc'
  secretKey: 'ea9e2dab'

Every key in settings is exposed on the root matrix object. For example, settings.apiKey is accessible in your MATRIX app as matrix.apiKey.

console.log(matrix.apiKey);// prints your apiKey setting

Dynamically Changing Settings from an application

Currently, the setting will only be overwritten after the MATRIX app restarts.

matrix.set({ apiKey: '3c3cce95' });// Overrides matrix.apiKey
matrix.set({ secretKey: '08937cef' });// Overrides matrix.apiKey

Local Database

MATRIX OS provides a local, file-based key-value store for app usage. This storage is globally accessible to any application installed on the same device.

It is not recommended to set end user specific configurations here. use settings instead.


Defines the name of the a key and the value it'll hold in the local database., value, function(){


Obtains the value of a stored key in the local database. The value is passed to the callback., function(error, value){
  console.log(value);// prints key value


Remove a stored key from the local database., function(){

File Storage

MATRIX applications utilize a local file storage for storing files. This enables MATRIX applications to dynamically download content that was not initially packaged with the app.


Downloads and stores a file specified through a URL.

  • url publicly accessible url.
  • filename name of the file being saved.
  • callback function to call when save is complete., filename, function(){


Load the buffer of a file you saved.

  • filename file to load.
  • callback function to call after file is read
matrix.file.load(filename, function(error, data){
  console.log(data);// prints buffer of loaded file


See all currently stored files in application.

  • callback function to call after files are counted
matrix.file.list(function(error, files){
  console.log(files);// prints array of downloaded files


  • filename file to remove from application storage
  • callback function to call when remove is complete
matrix.file.remove(filename, function(){