Android Setup

There are two methods available on Android to share settings between applications.

  • Provider Method - uses a content provider and broadcast receiver to share variables
  • File Method - uses an encrypted file to share variables.


For unity these additions will be automatically added to your build.

However if you have a manually control your manifest then these should be placed in your custom application AndroidManifest.xml file.

Provider Method

The provider method requires that you add several additions to the manifest. This includes a content provider and a broadcast receiver, along with some permissions and settings.

This method requires that you sign all of the applications with the same certificate. This is required so that the settings are secured between your applications.

<!-- For the content provider and broadcast receiver method -->
<meta-data android:name="app_group" android:value="[APPGROUP]" />
<meta-data android:name="app_authority" android:value="group.[APPID].provider" />
<meta-data android:name="app_authority_matcher" android:value="group\\.(?:[a-z,1-9]{1,}\\.)*provider" />
android:exported="true" >
android:exported="true" >
<action android:name="[APPGROUP]"/>

You should replace [APPGROUP] with your application group. This must be done in the meta-data tag and in the receiver. For example:

<meta-data android:name="app_group" android:value="" />

You also need to define an application authority, this must be different for each of your applications but must be matchable using the matcher. We suggest using the example above replacing [APPID] with your application id, for example an app_authority may be, as below:

<meta-data android:name="app_authority" android:value="" />

You must place the application authority both in the meta-data tag and in the provider.

File Method

The default is the provider method however if you wish to use the shared file method you can specify the type in the setup call:

"12345678", // salt
"", // app group identifier
AppGroupDefaults.TYPE_FILE // Android type

This method writes to a public file with the content encrypted.

This requires read / write permissions to the external storage:

<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

With recent versions of Android you will need to request runtime permissions to access the storage.

With AIR you can use the Permissions ANE to request the permissions at runtime.

Permissions.service.setPermissions( [
if (!Permissions.service.hasAuthorisation())

Unity you can use the UnityEngine.Android.Permission helper class to request permissions.

if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)
|| !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))