BackupAgent.OnRestore Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
OnRestore(BackupDataInput, Int32, ParcelFileDescriptor) |
The application is being restored from backup and should replace any existing data with the contents of the backup. |
OnRestore(BackupDataInput, Int64, ParcelFileDescriptor) |
New version of |
OnRestore(BackupDataInput, Int32, ParcelFileDescriptor)
The application is being restored from backup and should replace any existing data with the contents of the backup.
[Android.Runtime.Register("onRestore", "(Landroid/app/backup/BackupDataInput;ILandroid/os/ParcelFileDescriptor;)V", "GetOnRestore_Landroid_app_backup_BackupDataInput_ILandroid_os_ParcelFileDescriptor_Handler")]
public abstract void OnRestore (Android.App.Backup.BackupDataInput? data, int appVersionCode, Android.OS.ParcelFileDescriptor? newState);
[<Android.Runtime.Register("onRestore", "(Landroid/app/backup/BackupDataInput;ILandroid/os/ParcelFileDescriptor;)V", "GetOnRestore_Landroid_app_backup_BackupDataInput_ILandroid_os_ParcelFileDescriptor_Handler")>]
abstract member OnRestore : Android.App.Backup.BackupDataInput * int * Android.OS.ParcelFileDescriptor -> unit
Parameters
- data
- BackupDataInput
A structured wrapper around an open, read-only file descriptor pointing to a full snapshot of the application's data. The application should consume every entity represented in this data stream.
- appVersionCode
- Int32
The value of the android:versionCode
https://developer.android.com/guide/topics/manifest/manifest-element.html#vcode manifest attribute,
from the application that backed up this particular data set. This
makes it possible for an application's agent to distinguish among any
possible older data versions when asked to perform the restore
operation.
- newState
- ParcelFileDescriptor
An open, read/write ParcelFileDescriptor pointing to an
empty file. The application should record the final backup
state here after restoring its data from the data
stream.
When a full-backup dataset is being restored, this will be null
.
- Attributes
Exceptions
Remarks
The application is being restored from backup and should replace any existing data with the contents of the backup. The backup data is provided through the data
parameter. Once the restore is finished, the application should write a representation of the final state to the newState
file descriptor.
The application is responsible for properly erasing its old data and replacing it with the data supplied to this method. No "clear user data" operation will be performed automatically by the operating system. The exception to this is in the case of a failed restore attempt: if onRestore() throws an exception, the OS will assume that the application's data may now be in an incoherent state, and will clear it before proceeding.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
OnRestore(BackupDataInput, Int64, ParcelFileDescriptor)
New version of #onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor)
that handles a long app version code.
[Android.Runtime.Register("onRestore", "(Landroid/app/backup/BackupDataInput;JLandroid/os/ParcelFileDescriptor;)V", "GetOnRestore_Landroid_app_backup_BackupDataInput_JLandroid_os_ParcelFileDescriptor_Handler", ApiSince=28)]
public virtual void OnRestore (Android.App.Backup.BackupDataInput? data, long appVersionCode, Android.OS.ParcelFileDescriptor? newState);
[<Android.Runtime.Register("onRestore", "(Landroid/app/backup/BackupDataInput;JLandroid/os/ParcelFileDescriptor;)V", "GetOnRestore_Landroid_app_backup_BackupDataInput_JLandroid_os_ParcelFileDescriptor_Handler", ApiSince=28)>]
abstract member OnRestore : Android.App.Backup.BackupDataInput * int64 * Android.OS.ParcelFileDescriptor -> unit
override this.OnRestore : Android.App.Backup.BackupDataInput * int64 * Android.OS.ParcelFileDescriptor -> unit
Parameters
- data
- BackupDataInput
A structured wrapper around an open, read-only file descriptor pointing to a full snapshot of the application's data. The application should consume every entity represented in this data stream.
- appVersionCode
- Int64
The value of the <a
href="[TODO: @docRoot]guide/topics/manifest/manifest-element.html#vcode">android:versionCode
</a> manifest attribute,
from the application that backed up this particular data set. This
makes it possible for an application's agent to distinguish among any
possible older data versions when asked to perform the restore
operation.
- newState
- ParcelFileDescriptor
An open, read/write ParcelFileDescriptor pointing to an empty file. The application should record the final backup state here after restoring its data from the <code>data</code> stream. When a full-backup dataset is being restored, this will be <code>null</code>.
- Attributes
Remarks
New version of #onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor)
that handles a long app version code. Default implementation casts the version code to an int and calls #onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.