我从此链接安装了示例 BackupRestore。
我无法恢复数据。
OnBackup 和 OnCreate 被调用,但 OnRestore 没有。
我能够备份: OnCreate 和 OnBackup 受到打击,但 OnRestore 没有。
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
// Hold the lock while the FileBackupHelper restores the file from
// the data provided here.
synchronized (BackupRestoreActivity.sDataLock) {
super.onRestore(data, appVersionCode, newState);
}
}
public void onRestoreButtonClick(View v) {
Log.v(TAG, "Requesting restore of our most recent data");
mBackupManager.requestRestore(
new RestoreObserver() {
public void restoreFinished(int error) {
/** Done with the restore! Now draw the new state of our data */
Log.v(TAG, "Restore finished, error = " + error);
populateUI();
}
}
);
}
我试过使用 adb 工具(除了 requestRestore),它也不起作用。
adb shell bmgr restore [package]
adb uninstall [apkfile]
adb install [apkfile]
当我运行恢复时,我得到:
restoreStarting: 1 packages
restoreFinished: 0
done
但是 OnRestore 没有被命中,数据也没有恢复。
我正在使用 Android Studio 3.0。我为此花了很多时间。任何人都可以解释一下吗?