unable to call onBackup() method of BackupAgentHelper
<p>i am having class which takes backup of data and restore the same.</p>

<p>i have referred the example given in api demos.</p>

<p>bt it does not work at all.</p>

<p>Can anybody help me over this issue ????`</p>

<p>Android Manifest.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.kpbird.backupdemo"
      android:versionCode="1"
      android:versionName="1.0"&gt;


    &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:backupAgent="MyBackupAgent" android:restoreAnyVersion="true" android:allowBackup="true" android:enabled="true"&gt;
        &lt;activity android:name=".BackupServiceDemo"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;meta-data android:name="com.google.android.backup.api_key" android:value="AEdPqrEAAAAIAjALiYV5vv5cRGD5L649XByQMnFFYfApskNIfg" /&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>

<p>MyActivity.class</p>

<pre><code>public class BackupRestoreActivity extends Activity implements OnClickListener {

 BackupManager mBackupManager;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mBackupManager = new BackupManager(this);
        mBackupManager.dataChanged();

}
}
</code></pre>

<p>MyBackupAgent.class</p>

<pre><code>public class MyBackupAgent extends BackupAgentHelper {


    static final String MY_PREFS_BACKUP_KEY = "AEdPqrEAAAAIAjALiYV5vv5cRGD5L649XByQMnFFYfApskNIfg";
    static final String APP_DATA_KEY = "mydata";
    String TAG = this.getClass().getSimpleName();
    @Override
    public void onCreate() {

    Log.i("MyBackupAgent &gt;&gt;&gt;&gt;&gt;&gt; ","into Oncreate() of my Backup Agent &gt;&gt;&gt;&gt;");


    }

    @Override
    public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,ParcelFileDescriptor newState) throws IOException {

            Log.i(TAG, "I m onBackup");
          ByteArrayOutputStream bufStream = new ByteArrayOutputStream();
          DataOutputStream outWriter = new DataOutputStream(bufStream);
          outWriter.writeUTF("Hello Backup Service!");

          byte[] buffer = bufStream.toByteArray();
          int len = buffer.length;
          data.writeEntityHeader(APP_DATA_KEY, len);
          data.writeEntityData(buffer, len);

          FileOutputStream outstream = new FileOutputStream(newState.getFileDescriptor());
          DataOutputStream out = new DataOutputStream(outstream);
          out.writeUTF("Hello Backup Service!");
          Log.i(TAG, "Backup Message Completed");

    }

    @Override
    public void onRestore(BackupDataInput data, int appVersionCode,ParcelFileDescriptor newState) throws IOException {
        Log.i(TAG, "I m onRestore");
        while (data.readNextHeader()) {
               String key = data.getKey();
               int dataSize = data.getDataSize();
               if(key.equals(APP_DATA_KEY)){
                   byte[] dataBuf = new byte[dataSize];
                    data.readEntityData(dataBuf, 0, dataSize);
                    ByteArrayInputStream baStream = new ByteArrayInputStream(dataBuf);
                    DataInputStream in = new DataInputStream(baStream);
                    String read = in.readUTF();
                    Log.i(TAG, "Restored Message :" + read);
               }
               else{
                   data.skipEntityData();
               }

        }
    }
}
</code></pre>

<p>`</p>

<p>Thanks In Advance....</p>
