I've read through the documentation and other questions, but I guess I'm missing something. My BackupAgent's onCreate
is being called, but not its onBackup
, even when I call adb bmgr backup <package>
and then adb shell bmgr run
from command line. What part of the equation am I missing?
MyBackupAgent class:
public class MyBackupAgent extends BackupAgentHelper {
public MyBackupAgent() {
Log.d("GradeTracker.MyBackupAgent", "onCreate called");
String str = DBAdapter.DATABASE_NAME;
FileBackupHelper myDb = new FileBackupHelper(this, "../databases/" + str);
addHelper(DBAdapter.DATABASE_NAME , myDb);
}
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
Log.d("GradeTracker.MyBackupAgent", "onBackup called");
synchronized (DBAdapter.dbBackupLockObject) {
super.onBackup(oldState, data, newState);
}
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
Log.d("GradeTracker.MyBackupAgent", "onRestore called");
synchronized (DBAdapter.dbBackupLockObject) {
super.onRestore(data, appVersionCode, newState);
}
}
}
In my Manifest:
<application
android:allowBackup="true"
android:backupAgent="MyBackupAgent"
...
<meta-data android:name="com.google.android.backup.api_key"
android:value="<my_key>" />
I only registered my app with Android Backup Services a few hours ago, but it didn't say I'd have to wait. What am I missing?
Turns out the code I thought I was running in onCreate()
I was actually running in the constructor. I don't even have an onCreate. >.<