# SaveSharedVariable

## Description

Saves a variable so it can be accessed from other apps. This only works on iOS and Android platforms, and apps can only share a variable if they meet certain requirements based on the platform.
On iOS the apps must have the same Bundle Seed ID (also called App ID Prefix) and have the same explicit App ID up to the last dot. For example com.mycompany.mygroup.myapp1 and com.mycompany.mygroup.myapp2 would be able to share varaibles.
On Android the apps must have the WRITE_EXTERNAL_STORAGE permission and have the same package name up to the last dot. For example com.mycompany.mygroup.myapp1 and com.mycompany.mygroup.myapp2 would be able to share varaibles. On Android shared variables are written to a user accesible location, so be aware that users may be able to read and/or edit the variables that you save.
Variables are identified by name, so using SaveSharedVariable("username", "Alice") will set the variable called "username" to the value "Alice". This can then be read by other apps by using LoadSharedVariables( "username", "" ) If two apps save different values to the same variable name then the value will be overwriten and only the most recent value will be accessible. Variable values will persist even if the app is deleted and re-installed. You should not use this command to store any sensitive information such as passwords in plain text. On iOS the length of the variable name plus the length of your App ID up to the last dot (e.g. com.mycompany.mygroup) must be less than 58.

## Definition

SaveSharedVariable( varName, varValue )

void agk::SaveSharedVariable( const char *varName, const char *varValue )

## Parameters

- varName - The name to use to identify this variable
- varValue - The value to save in this variable