Android – How to add android:allowBackup=”false” via cordova plugin

androidandroid-manifestcordovacordova-plugins

I am now developing a Cordova Plugin, I wanna add

  android:allowBackup="true"

into AndroidManifest.xml, but I do not know how to specify it in plugin.xml.

Best Solution

Answer shared by @Muhammad Omar works for cordova-android < 7. But things changed for cordova-android >= 7

https://cordova.apache.org/announcements/2017/12/04/cordova-android-7.0.0.html

So you need to change it a bit for

cordova-android >= 7

<platform name="android">
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:allowBackup="false"/>
    </edit-config>
</platform>

cordova-android < 7

The configuration edit that has worked for me was:

<platform name="android">
    <edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
        <application android:allowBackup="false"/>
    </edit-config>
</platform>