Android: BackupAgentHelper isn’t getting called on backup

1153090 pts.
Tags:
Android
Backup
We're trying to backup data in Android using MyBackUpAgent class (which extends the BackupAgentHelper). We have been using SharedPreferences to store data. Here's what our code looks like:
public class MainActivity extends Activity {
    EditText inputtext; 
    TextView outputtext; 
    Button submit;   
    public static SharedPreferences sharedprefs;
    static final String File_Name_Of_Prefrences ="godplay_preferences";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);

        init();      
        sharedprefs=getSharedPreferences(File_Name_Of_Prefrences,MODE_PRIVATE);
        System.out.println("value="+sharedprefs.getString("Input",""));
        outputtext.setText(sharedprefs.getString("Input",""));


        submit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                populateUI();
            }
        });
    }

    public void populateUI()
    {
        String savedinput=inputtext.getText().toString();
        System.out.println("savedinput="+savedinput);
        outputtext.setText(savedinput);
        sharedprefs=getSharedPreferences(File_Name_Of_Prefrences,MODE_PRIVATE);
        Editor editor=sharedprefs.edit();
        editor.putString("Input",inputtext.getText().toString());
        editor.commit();
        requestBackup();
    }

    private void init() throws ClassCastException
    {
        inputtext=(EditText) findViewById(R.id.edtInputText);
        outputtext=(TextView) findViewById(R.id.txtOutputText);
        submit=(Button) findViewById(R.id.btnSubmit);
    }

    public void requestBackup() {
        BackupManager bm = new BackupManager(getApplicationContext());
        bm.dataChanged();
    }
}
Here's the BackupAgentClass:
public class MyBackUpAgent extends BackupAgentHelper{
static final String PREFS_BACKUP_KEY = "backup";
       String key_string="Hello World";

     @Override
       public void onCreate() {
    System.out.println("********************");
    SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this,MainActivity.File_Name_Of_Prefrences);
    addHelper(PREFS_BACKUP_KEY, helper);

     } 
}
And the manifest.xml file:

But when we do this test on an Android device/emulator, the backup isn't happening. Are we doing something wrong here? Thanks! 
							
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: