Skip to content

Commit 7e876db

Browse files
docs(secure-preferences): update README.md
1 parent ee9e750 commit 7e876db

1 file changed

Lines changed: 47 additions & 6 deletions

File tree

packages/secure-preferences/README.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,60 @@ npx cap sync
3939

4040
### Android
4141

42-
#### Proguard
42+
#### Backup rules
4343

44-
If you are using Proguard, you need to add the following rules to your `proguard-rules.pro` file:
44+
To prevent the preferences file from being backed up to the cloud, you need to add backup rules to your Android project.
45+
You can read more about this in the [Android documentation](https://developer.android.com/identity/data/autobackup#IncludingFiles).
46+
47+
##### Android 11 and lower
4548

49+
Add the `android:fullBackupContent` attribute to the `<application>` tag in your `AndroidManifest.xml` file:
50+
51+
```xml
52+
<application
53+
android:fullBackupContent="@xml/full_backup_content">
54+
</application>
4655
```
47-
-keep class io.capawesome.capacitorjs.plugins.** { *; }
56+
57+
Create a new file `res/xml/full_backup_content.xml` with the following content:
58+
59+
```xml
60+
<?xml version="1.0" encoding="utf-8"?>
61+
<full-backup-content>
62+
<include domain="sharedpref" path="."/>
63+
<exclude domain="sharedpref" path="CAPAWESOME_SECURE_PREFERENCES.xml"/>
64+
</full-backup-content>
4865
```
4966

50-
#### Variables
67+
##### Android 12 and higher
68+
69+
Add the `android:dataExtractionRules` attribute to the `<application>` tag in your `AndroidManifest.xml` file:
70+
71+
```xml
72+
<application
73+
android:dataExtractionRules="@xml/data_extraction_rules">
74+
</application>
75+
```
5176

52-
This plugin will use the following project variables (defined in your app’s `variables.gradle` file):
77+
Create a new file `res/xml/data_extraction_rules.xml` with the following content:
5378

54-
- `$androidxSecurityCryptoVersion` version of `androidx.security:security-crypto` (default: `1.0.0`)
79+
```xml
80+
<?xml version="1.0" encoding="utf-8"?>
81+
<data-extraction-rules>
82+
<cloud-backup [disableIfNoEncryptionCapabilities="true|false"]>
83+
<include domain="sharedpref" path="."/>
84+
<exclude domain="sharedpref" path="device.xml"/>
85+
</cloud-backup>
86+
</data-extraction-rules>
87+
```
88+
89+
#### Proguard
90+
91+
If you are using Proguard, you need to add the following rules to your `proguard-rules.pro` file:
92+
93+
```
94+
-keep class io.capawesome.capacitorjs.plugins.** { *; }
95+
```
5596

5697
## Configuration
5798

0 commit comments

Comments
 (0)