android - Why is my onBackup() method for my BackupAgentHelper not being called? -
i've read through documentation , other questions, guess i'm missing something. backupagent's oncreate
being called, not onbackup
, when call adb bmgr backup <package>
, adb shell bmgr run
command line. part of equation 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 manifest:
<application android:allowbackup="true" android:backupagent="mybackupagent" ... <meta-data android:name="com.google.android.backup.api_key" android:value="<my_key>" />
i registered app android backup services few hours ago, didn't i'd have wait. missing?
turns out code thought running in oncreate()
running in constructor. don't have oncreate. >.<
Comments
Post a Comment