Android BackupAgent不备份/恢复共享偏好

时间:2013-09-20 17:03:04

标签: java android backup

我尝试使用BackupAgent备份我的默认sharedpreferences。这就是我对MyBackupAgent

的看法
public class MyBackupAgent extends BackupAgentHelper {

    // The name of the SharedPreferences file
    private final String PREFS = "com.mikebdev.refuelpro_preferences";

    // A key to uniquely identify the set of backup data
    private static final String PREFS_BACKUP_KEY = "prefs";


    @Override
    public void onCreate() {
        SharedPreferencesBackupHelper sharedPref = new SharedPreferencesBackupHelper(this, PREFS);
        addHelper(PREFS_BACKUP_KEY, sharedPref);

    }
}

从ADB强制备份和还原时,这就是我在控制台中获得的内容:

shell@flo:/ $ bmgr backup com.mikebdev.refuelpro
bmgr backup com.mikebdev.refuelpro
shell@flo:/ $ bmgr backup run
bmgr backup run
shell@flo:/ $ bmgr restore com.mikebdev.refuelpro
bmgr restore com.mikebdev.refuelpro
restoreStarting: 2 packages
restoreFinished: 0
done

这就是Logcat所说的:

09-20 18:47:32.125      525-539/? I/BackupManagerService﹕ Scheduling backup for new app com.mikebdev.refuelpro
09-20 18:47:32.125      525-539/? D/BackupManagerService﹕ Now staging backup of com.mikebdev.refuelpro
09-20 18:47:32.966     525-2458/? D/BackupManagerService﹕ agentConnected pkg=com.mikebdev.refuelpro agent=android.os.BinderProxy@42222800
09-20 18:52:00.336      525-539/? D/BackupManagerService﹕ Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.mikebdev.refuelpro flg=0x8000010 (has extras) }
09-20 18:52:00.336      525-539/? V/BackupManagerService﹕ removePackageParticipantsLocked: uid=10084 #1
09-20 18:52:08.344      525-546/? V/BackupManagerService﹕ restoreAtInstall pkg=com.mikebdev.refuelpro token=f restoreSet=39fa49811177c60b
09-20 18:52:08.354      525-657/? D/BackupManagerService﹕ MSG_RUN_RESTORE observer=null
09-20 18:52:08.935      525-657/? D/BackupManagerService﹕ initiateOneRestore packageName=@pm@
09-20 18:52:08.945      525-657/? V/BackupServiceBinder﹕ doRestore() invoked
09-20 18:52:08.945      525-657/? V/BackupManagerService﹕ No next package, finishing restore
09-20 18:52:08.945      525-657/? I/BackupManagerService﹕ Restore complete.

所以现在我想知道发生了什么事,因为我不知道。我不知道为什么这不起作用。

而且,我究竟会用这项服务备份一个小的SQLite数据库?

提前致谢

0 个答案:

没有答案