title: Android BackupAgent not working
body: <p>I am trying to get the BackupAgent working but I can't get it to work. Here is my sample code:</p>
  
  <p>The layout is just a TextView and a Button.</p>
  
  <p>MainActivity:</p>
  
  <pre><code>...     
  public static final String PREF_NAME = "TestPref";
      private static final String TEST_KEY = "TEST";
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      final SharedPreferences pref = getApplicationContext()
              .getSharedPreferences(PREF_NAME, MODE_PRIVATE);
  
      if (pref.getString(TEST_KEY, "").length() == 0) {
          pref.edit().putString(TEST_KEY, "new Date())
                  .commit();
          new BackupManager(getApplicationContext()).dataChanged();
      }
  
      Button button = (Button) findViewById(R.id.button1);
      button.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              TextView tv = (TextView) findViewById(R.id.textView1);
              if ("START_VALUE".equalsIgnoreCase(tv.getText().toString())) {
                  tv.setText(pref.getString(TEST_KEY, ""));
              }
          }
      });
  }
  </code></pre>
  
  <p>The BackupHelper is just the ones I available here: <a href="http://developer.android.com/reference/android/app/backup/SharedPreferencesBackupHelper.html" rel="nofollow">http://developer.android.com/reference/android/app/backup/SharedPreferencesBackupHelper.html</a>
  I adjusted the name of the pref file with the one I used.</p>
  
  <p>And in the Manifest I added 
   <code>android:backupAgent="TheBackupAgent"</code> (application tag)
  and the backup-meta data</p>
  
  <pre><code> &lt;meta-data android:name="com.google.android.backup.api_key"
            android:value="{registered_key}" /&gt;
  </code></pre>
  
  <p>So its really a very simple app. </p>
  
  <p>I am doing the following now: </p>
  
  <p>1)Starting app</p>
  
  <p>2) Textview is initialized with "START_VALUE" in xml file, so I press the Button and the pref-value is displayed</p>
  
  <p>3) I run "adb shell bmgr run" from the console to run the backup immediately</p>
  
  <p>4) I run "adb uninstall com.foo.backuptest"</p>
  
  <p>5) I run "adb install com.foo.backuptest"</p>
  
  <p>Now the value (timestamp) is not restored from the cloud. A new one is generated. </p>
  
  <p>Where is my error??</p>