My app takes a cloud-based backup on Google Drive. The backup occurs smoothly.
I use the following code for backup:
void saveToDrive() {
// Code to upload file
DriveId mDriveId = metadataResult.getMetadata().getDriveId();
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getApplicationContext().getPackageName(), MODE_PRIVATE);
sharedPreferences.edit().putString("DriveId", mDriveId.encodeToString()).apply();
....
}
As you can see, I save the DriveId
to SharedPreferences
when I backup. So using that DriveId
, I can restore as:
void readFromDrive(DriveId mDriveId) { // DriveId is not available after app reinstall!!
// Code to download file and restore
}
My restore operation requires a DriveId
to download the backed-up file. I want to trigger a restore when the app is reinstalled. But, I am not able to get the DriveId
so that I may download the required file.
How do I do that? Please, I am desperate for some help.
Thanks.