Reputation: 601
I have implemented Google Drive backup in my app.
I upload the backup in the App Folder
. But after I reinstall my app, it is not able to find the newly created file.
I there any workaround for this?
Thanks.
Upvotes: 0
Views: 364
Reputation: 601
I did the following:
requestSync(GoogleApiClient)
Drive.DriveApi.query(GoogleApiClient, query)
The snippet is given below for those interested.
@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
Drive.DriveApi.requestSync(getGoogleApiClient()).setResultCallback(syncCallback);
}
final private ResultCallback<Status> syncCallback = new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (!status.isSuccess()) {
showMessage("Problem while retrieving results");
return;
}
query = new Query.Builder()
.addFilter(Filters.and(Filters.eq(SearchableField.TITLE, "title"),
Filters.eq(SearchableField.TRASHED, false)))
.build();
Drive.DriveApi.query(getGoogleApiClient(), query)
.setResultCallback(metadataCallback);
}
};
final private ResultCallback<DriveApi.MetadataBufferResult> metadataCallback =
new ResultCallback<DriveApi.MetadataBufferResult>() {
@SuppressLint("SetTextI18n")
@Override
public void onResult(@NonNull DriveApi.MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Problem while retrieving results");
return;
}
MetadataBuffer mdb = result.getMetadataBuffer();
for (Metadata md : mdb) {
Date createdDate = md.getCreatedDate();
DriveId driveId = md.getDriveId();
}
readFromDrive(driveId);
}
};
Thanks for all your help!
Upvotes: 1
Reputation: 2998
Uninstalling your application will remove data in App Folder as well. This is from the REST API documentation, but I'm guessing the same thing happens on Android and other client APIs as well.
Upvotes: 1