我尝试向我的应用添加备份支持,并按照Data Backup guide中的说明设置了BackupAgentHelper的子类。我已经将我的代码与其他几个教程和SO帖子进行了比较,并且没有看到任何问题:
public class MyBackupClass extends BackupAgentHelper {
public App app;
@Override
public void onCreate() {
Log.d("MyBackupClass", "** onCreate **");
// get the application delegate for convenience
this.app = (App)this.getApplicationContext();
// add the backup helpers
this.addHelpers();
}
public void addHelpers() {
Log.d("MyBackupClass", "** addHelpers **");
String name = "Sample Database";
// add a helper for the default shared preferences
String defaultSharedPrefsName = this.getPackageName() + "_preferences";
SharedPreferencesBackupHelper defaultPrefsHelper = new SharedPreferencesBackupHelper(this, defaultSharedPrefsName);
addHelper("default_prefs", defaultPrefsHelper);
// add a helper for the shared preferences
SharedPreferencesBackupHelper prefsHelper = new SharedPreferencesBackupHelper(this, name);
addHelper(name + "_prefs", prefsHelper);
// add a helper for the data file
FileBackupHelper dataHelper = new FileBackupHelper(this, name);
addHelper(name + "_data", dataHelper);
}
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException {
// hold the lock while the FileBackupHelper performs the backup
synchronized (this.app.database.fileLock) {
Log.d("MyBackupClass", "** onBackup **");
super.onBackup(oldState, data, newState);
}
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
// hold the lock while the FileBackupHelper restores the file
synchronized (this.app.database.fileLock) {
Log.d("MyBackupClass", "** onRestore **");
super.onRestore(data, appVersionCode, newState);
}
}
}
每当我保存数据时,我也会运行new BackupManager(this.app).dataChanged()
。
在已登录Google Play帐户且设备设置中启用了备份和还原选项的设备上,我运行./adb -d shell bmgr run
并在logcat中获取此结果:
D/AndroidRuntime( 3828):
D/AndroidRuntime( 3828): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 3828): CheckJNI is OFF
D/dalvikvm( 3828): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 3828): Added shared lib libjavacore.so 0x0
D/dalvikvm( 3828): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 3828): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 3828): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 3828): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 3828): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 3828): failed to load memtrack module: -2
D/AndroidRuntime( 3828): Calling main entry com.android.commands.bmgr.Bmgr
V/BackupManagerService( 433): Scheduling immediate backup pass
D/AndroidRuntime( 3828): Shutting down VM
D/dalvikvm( 3828): Debugger has detached; object registry had 1 entries
V/BackupManagerService( 433): Running a backup pass
V/BackupManagerService( 433): clearing pending backups
V/PerformBackupTask( 433): Beginning backup of 2 targets
V/BackupServiceBinder( 433): doBackup() invoked
D/PerformBackupTask( 433): invokeAgentForBackup on @pm@
I/PerformBackupTask( 433): no backup data written; not calling transport
D/PerformBackupTask( 433): starting agent for backup of BackupRequest{pkg=android}
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{4196f698 android}
D/BackupManagerService( 433): agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupServiceBinder@4203c550
I/BackupManagerService( 433): got agent android.app.backup.BackupAgent$BackupServiceBinder@4203c550
V/BackupServiceBinder( 433): doBackup() invoked
D/BackupHelperDispatcher( 433): handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper@4226bb08
D/PerformBackupTask( 433): invokeAgentForBackup on android
D/PerformBackupTask( 433): starting agent for backup of BackupRequest{pkg=com.arlomedia.myapp}
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{41e916b0 com.arlomedia.myapp}
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
D/BackupManagerService( 433): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy@41e45118
I/BackupManagerService( 433): got agent android.app.IBackupAgent$Stub$Proxy@421a63e8
V/BackupServiceBinder( 3779): doBackup() invoked
D/MyBackupClass ( 3779): ** onBackup **
D/BackupHelperDispatcher( 3779): handling new helper 'Sample Database_data'
D/PerformBackupTask( 433): invokeAgentForBackup on com.arlomedia.myapp
D/BackupHelperDispatcher( 3779): handling new helper 'Sample Database_prefs'
D/BackupHelperDispatcher( 3779): handling new helper 'default_prefs'
I/PerformBackupTask( 433): Backup pass finished.
关于处理我设置的帮助程序的部分,&#34;备份传递已完成&#34;似乎表明备份正在运行。然后,我卸载应用程序并使用./adb -d install
重新安装它并获得以下结果:
D/AndroidRuntime( 3875): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 3875): CheckJNI is OFF
D/dalvikvm( 3875): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 3875): Added shared lib libjavacore.so 0x0
D/dalvikvm( 3875): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 3875): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 3875): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 3875): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 3875): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 3875): failed to load memtrack module: -2
D/AndroidRuntime( 3875): Calling main entry com.android.commands.pm.Pm
D/Finsky (23657): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 142
W/ActivityManager( 433): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
D/Finsky (23657): [1] WorkerTask.onPreExecute: Verification Requested for id = 142, data=file:///data/local/tmp/app-debug.apk flags=112 fromVerificationActivity=false
D/dalvikvm(23657): GC_CONCURRENT freed 1940K, 21% free 8146K/10228K, paused 2ms+1ms, total 34ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 993K, 21% free 8130K/10228K, paused 23ms, total 24ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 980K, 21% free 8136K/10228K, paused 23ms, total 23ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 1051K, 20% free 8208K/10228K, paused 23ms, total 23ms
I/qtaguid (23657): Failed write_ctrl(u 74) res=-1 errno=22
I/qtaguid (23657): Untagging socket 74 failed errno=-22
W/NetworkManagementSocketTagger(23657): untagSocket(74) failed with errno -22
D/Finsky (23657): [1] 2.onResponse: Verification id=142 response=0
D/Finsky (23657): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 142
W/ActivityManager( 433): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
I/PackageManager( 433): Copying native libraries to /data/app-lib/vmdl-2084848498
D/dalvikvm( 433): GC_CONCURRENT freed 2945K, 34% free 14565K/21864K, paused 4ms+6ms, total 62ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 14ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 14ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 46ms
I/PackageManager( 433): Running dexopt on: com.arlomedia.myapp
D/dalvikvm( 3888): DexOpt: load 64ms, verify+opt 570ms, 2417268 bytes
D/Finsky (23657): [1] 5.onFinished: Installation state replication succeeded.
I/ActivityManager( 433): Force stopping com.arlomedia.myapp appid=10140 user=-1: update pkg
V/BackupManagerService( 433): restoreAtInstall pkg=com.arlomedia.myapp token=8f restoreSet=3c51dd81eebd5a3d
D/BackupManagerService( 433): MSG_RUN_RESTORE observer=null
V/BackupServiceBinder( 433): doRestore() invoked
D/BackupManagerService( 433): initiateOneRestore packageName=@pm@
V/BackupManagerService( 433): Package com.arlomedia.myapp restore version [25] is compatible with installed version [25]
I/ActivityManager( 433): Start proc com.arlomedia.myapp for backup com.arlomedia.myapp/.helpers.Backups: pid=3889 uid=10140 gids={50140, 3003, 1028, 1015}
D/dalvikvm( 3889): Late-enabling CheckJNI
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{4226acf0 com.arlomedia.myapp}
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
D/BackupManagerService( 433): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy@423dd558
I/BackupManagerService( 433): got agent android.app.IBackupAgent$Stub$Proxy@41d66818
D/BackupManagerService( 433): initiateOneRestore packageName=com.arlomedia.myapp
V/BackupServiceBinder( 3889): doRestore() invoked
D/MyBackupClass ( 3779): ** onRestore **
D/backup_data( 3889): SKIP_PADDING FAILED at line 332
V/BackupManagerService( 433): No next package, finishing restore
I/BackupManagerService( 433): Restore complete.
关于&#34;恢复版本的部分兼容&#34;并且&#34;恢复完整&#34;看起来很有希望,但没有数据恢复。我看到错误&#34; SKIP_PADDING FAILED,&#34;但我不知道这与我正在做什么或如何修复它有关。
我还尝试使用本地传输的模拟器。运行备份管理器会得到以下结果:
D/AndroidRuntime( 5503):
D/AndroidRuntime( 5503): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
W/linker ( 5503): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/AndroidRuntime( 5503): CheckJNI is ON
D/dalvikvm( 5503): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5503): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5503): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5503): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5503): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 5503): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5503): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5503): failed to load memtrack module: -2
D/AndroidRuntime( 5503): Calling main entry com.android.commands.bmgr.Bmgr
V/BackupServiceBinder( 1276): doBackup() invoked
V/BackupManagerService( 1276): Scheduling immediate backup pass
V/BackupManagerService( 1276): Running a backup pass
V/BackupManagerService( 1276): clearing pending backups
V/PerformBackupTask( 1276): Beginning backup of 2 targets
D/PerformBackupTask( 1276): invokeAgentForBackup on @pm@
I/PerformBackupTask( 1276): no backup data written; not calling transport
D/PerformBackupTask( 1276): starting agent for backup of BackupRequest{pkg=android}
D/BackupManagerService( 1276): awaiting agent for ApplicationInfo{b10042c8 android}
V/BackupServiceBinder( 1276): doBackup() invoked
D/BackupHelperDispatcher( 1276): handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper@b12f0e70
V/LocalTransport( 1276): performBackup() pkg=android
V/LocalTransport( 1276): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=-1 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJfaW5mby54bWw=
V/LocalTransport( 1276): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=115 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJfaW5mby54bWw=
V/LocalTransport( 1276): data size 115
V/LocalTransport( 1276): finishBackup()
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
V/BackupServiceBinder( 5427): doBackup() invoked
D/MyBackupClass ( 3779): ** onBackup **
D/BackupHelperDispatcher( 5427): handling new helper 'Sample Database_data'
D/BackupHelperDispatcher( 5427): handling new helper 'Sample Database_prefs'
D/BackupHelperDispatcher( 5427): handling new helper 'default_prefs'
V/LocalTransport( 1276): performBackup() pkg=com.arlomedia.myapp
V/LocalTransport( 1276): Got change set key=Sample Database_data:Sample Database size=1755 key64=U2FtcGxlIERhdGFiYXNlX2RhdGE6U2FtcGxlIERhdGFiYXNl
V/LocalTransport( 1276): data size 1755
V/LocalTransport( 1276): Got change set key=Sample Database_prefs:Sample Database size=4186 key64=U2FtcGxlIERhdGFiYXNlX3ByZWZzOlNhbXBsZSBEYXRhYmFzZQ==
V/LocalTransport( 1276): data size 4186
V/LocalTransport( 1276): Got change set key=default_prefs:com.arlomedia.myapp_preferences size=356 key64=ZGVmYXVsdF9wcmVmczpjb20uYXJsb21lZGlhLnNldGxpc3RtYWtlcl9wcmVmZXJlbmNlcw==
V/LocalTransport( 1276): data size 356
V/LocalTransport( 1276): finishBackup()
D/BackupManagerService( 1276): agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupServiceBinder@b1382ba0
I/BackupManagerService( 1276): got agent android.app.backup.BackupAgent$BackupServiceBinder@b1382ba0
D/PerformBackupTask( 1276): invokeAgentForBackup on android
D/PerformBackupTask( 1276): starting agent for backup of BackupRequest{pkg=com.arlomedia.myapp}
D/BackupManagerService( 1276): awaiting agent for ApplicationInfo{b158e9a8 com.arlomedia.myapp}
D/BackupManagerService( 1276): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy@b13cdbf0
I/BackupManagerService( 1276): got agent android.app.IBackupAgent$Stub$Proxy@b13ad550
D/PerformBackupTask( 1276): invokeAgentForBackup on com.arlomedia.myapp
I/PerformBackupTask( 1276): Backup pass finished.
D/AndroidRuntime( 5503): Shutting down VM
D/dalvikvm( 5503): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 5503): NOTE: attach of thread 'Binder_1' failed
重新安装会产生以下结果:
D/AndroidRuntime( 5530):
D/AndroidRuntime( 5530): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
W/linker ( 5530): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/AndroidRuntime( 5530): CheckJNI is ON
D/dalvikvm( 5530): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5530): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5530): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5530): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5530): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 5530): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5530): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5530): failed to load memtrack module: -2
D/AndroidRuntime( 5530): Calling main entry com.android.commands.pm.Pm
W/ActivityManager( 1276): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
W/ActivityManager( 1276): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
I/PackageManager( 1276): Copying native libraries to /data/app-lib/vmdl2051152188
D/dalvikvm( 1276): GC_FOR_ALLOC freed 1352K, 21% free 7636K/9604K, paused 6ms, total 8ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 1002K, 19% free 7834K/9604K, paused 66ms, total 66ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 947K, 19% free 7840K/9604K, paused 7ms, total 7ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 946K, 19% free 7848K/9604K, paused 9ms, total 10ms
I/PackageManager( 1276): Running dexopt on: com.arlomedia.myapp
W/linker ( 5542): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/dalvikvm( 5542): DexOpt: load 15ms, verify+opt 149ms, 2414236 bytes
I/ActivityManager( 1276): Force stopping com.arlomedia.myapp appid=10067 user=-1: update pkg
W/PackageManager( 1276): Unknown permission com.android.vending.CHECK_LICENSE in package com.arlomedia.myapp
W/PackageManager( 1276): Unknown permission com.android.vending.BILLING in package com.arlomedia.myapp
V/LocalTransport( 1276): start restore 1
V/LocalTransport( 1276): nextRestorePackage() = @pm@
V/LocalTransport( 1276): getRestoreData() found 10 key files
V/LocalTransport( 1276): ... key=@meta@ size=0
V/LocalTransport( 1276): ... key=com.android.calendar size=0
V/LocalTransport( 1276): ... key=com.android.browser size=0
V/LocalTransport( 1276): ... key=com.android.providers.userdictionary size=0
V/LocalTransport( 1276): ... key=com.android.sharedstoragebackup size=0
V/LocalTransport( 1276): ... key=android size=0
V/LocalTransport( 1276): ... key=com.android.dialer size=0
V/LocalTransport( 1276): ... key=com.android.providers.settings size=0
V/LocalTransport( 1276): ... key=com.arlomedia.myapp size=635
V/LocalTransport( 1276): ... key=com.arlomedia.myotherapp size=635
V/BackupServiceBinder( 1276): doRestore() invoked
D/BackupServiceBinder( 1276): onRestore (com.android.server.PackageManagerBackupAgent) threw
D/BackupServiceBinder( 1276): java.io.EOFException
D/BackupServiceBinder( 1276): at libcore.io.Streams.readFully(Streams.java:83)
D/BackupServiceBinder( 1276): at java.io.DataInputStream.readInt(DataInputStream.java:103)
D/BackupServiceBinder( 1276): at com.android.server.PackageManagerBackupAgent.onRestore(PackageManagerBackupAgent.java:273)
D/BackupServiceBinder( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:599)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.initiateOneRestore(BackupManagerService.java:4842)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.restorePmMetadata(BackupManagerService.java:4595)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.execute(BackupManagerService.java:4453)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$BackupHandler.handleMessage(BackupManagerService.java:573)
D/BackupServiceBinder( 1276): at android.os.Handler.dispatchMessage(Handler.java:102)
D/BackupServiceBinder( 1276): at android.os.Looper.loop(Looper.java:136)
D/BackupServiceBinder( 1276): at android.os.HandlerThread.run(HandlerThread.java:61)
V/LocalTransport( 1276): nextRestorePackage() = com.arlomedia.myapp
V/LocalTransport( 1276): no more packages to restore
V/LocalTransport( 1276): finishRestore()
V/BackupManagerService( 1276): restoreAtInstall pkg=com.arlomedia.myapp token=17 restoreSet=1
D/BackupManagerService( 1276): MSG_RUN_RESTORE observer=null
D/BackupManagerService( 1276): initiateOneRestore packageName=@pm@
E/BackupManagerService( 1276): Unable to call app for restore: @pm@
E/BackupManagerService( 1276): java.lang.RuntimeException: java.io.EOFException
E/BackupManagerService( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:602)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.initiateOneRestore(BackupManagerService.java:4842)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.restorePmMetadata(BackupManagerService.java:4595)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.execute(BackupManagerService.java:4453)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$BackupHandler.handleMessage(BackupManagerService.java:573)
E/BackupManagerService( 1276): at android.os.Handler.dispatchMessage(Handler.java:102)
E/BackupManagerService( 1276): at android.os.Looper.loop(Looper.java:136)
E/BackupManagerService( 1276): at android.os.HandlerThread.run(HandlerThread.java:61)
E/BackupManagerService( 1276): Caused by: java.io.EOFException
E/BackupManagerService( 1276): at libcore.io.Streams.readFully(Streams.java:83)
E/BackupManagerService( 1276): at java.io.DataInputStream.readInt(DataInputStream.java:103)
E/BackupManagerService( 1276): at com.android.server.PackageManagerBackupAgent.onRestore(PackageManagerBackupAgent.java:273)
E/BackupManagerService( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:599)
E/BackupManagerService( 1276): ... 7 more
W/BackupManagerService( 1276): Tried to clear data for @pm@ but not found
E/BackupManagerService( 1276): No restore metadata available, so not restoring settings
W/PMBA ( 1276): getRestoredMetadata() before metadata read!
E/BackupManagerService( 1276): Missing metadata for com.arlomedia.myapp
V/BackupManagerService( 1276): No next package, finishing restore
I/BackupManagerService( 1276): Restore complete.
在这种情况下,备份过程显示备份数据的大小,这更有希望,但随后恢复过程因EOFException而崩溃,我不知道如何解决这个问题。没有任何东西可以恢复。
最终我只需要在真实设备上工作,但我会在模拟器中发布结果,以防它提供任何线索。
任何人都可以帮我解释这些日志以找出错误吗?
我也很欣赏快速评论,说明你是否已经开始使用这个系统,因为有几个SO线程没有得到答复,或者得出结论认为系统无法正常工作。
更新
在进一步研究这些日志之后,从设备或仿真器备份时似乎没有相关的错误,但在恢复每个日期时在关键点发生了不同的错误 - 设备上的SKIP_PADDING FAILED和模拟器上的EOFException。 SKIP_PADDING FAILED在这两个未回答的问题中提及:
backup_data: SKIP_PADDING FAILED at line X
我尝试阅读source code SKIP_PADDING FAILED,但无法理解它在做什么。接下来,我将此代码添加到我的onRestore方法中,以查看BackupDataInput对象是否包含我的数据:
while (data.readNextHeader()) {
String key = data.getKey();
int dataSize = data.getDataSize();
byte[] buffer = new byte[dataSize];
data.readEntityData(buffer, 0, dataSize);
Log.d("Backups", "restoring key " + key);
Log.d("Backups", "restoring data size " + dataSize);
Log.d("Backups", "restoring data " + new String(buffer, "UTF-8"));
}
确实如此!所以现在我可以看到我的数据正在备份,但BackupAgent.performRestore(由BackupAgentHelper.onRestore调用)中的某些内容正在中断。我想我可以通过在onRestore方法中保存数据文件来解决这个问题。有没有人有更好的解决方案?
答案 0 :(得分:1)
一周后我回来了,再次尝试,现在备份正在恢复。我现在无法识别出我正在做的任何事情,所以我无法解决之前发生的任何问题。但是现在它正在运行,我可以澄清一些关于Android备份服务的事情: