#!/usr/bin/env node

module.exports = function(context) {

  var fs = context.requireCordovaModule('fs'),
    path = context.requireCordovaModule('path');

  var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');


  var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');

  if (fs.existsSync(manifestFile)) {

    fs.readFile(manifestFile, 'utf8', function (err,data) {
      if (err) {
        throw new Error('Unable to find AndroidManifest.xml: ' + err);
      }
      var appClass = 'android:allowBackup="true"';
      if (data.indexOf(appClass) == -1) {
        var result = data.replace(/<application/g, '<application ' + appClass + '"');
        fs.writeFile(manifestFile, result, 'utf8', function (err) {
          if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
        })
      }
    });
  }


};

@@ -516,16 +516,17 @@
 lass = '
+ 
 android:
@@ -543,16 +543,17 @@
 p=%22true%22
+ 
 ';%0A     
@@ -673,11 +673,8 @@
 s + 
-'%22'
 );%0A 

Update androidBeforeInstall.js