Android:应用程序重新安装后找不到应用程序文件夹中的已上传文件

问题描述:

我在我的应用程序中实施了Google Drive备份。Android:应用程序重新安装后找不到应用程序文件夹中的已上传文件

我上传备份在App Folder。但是在我重新安装我的应用程序后,它无法找到新创建的文件。

我有没有解决这个问题的方法?

感谢。

我做了以下内容:

  1. 我用requestSync(GoogleApiClient)
  2. 然后,在其回调,我查询使用Drive.DriveApi.query(GoogleApiClient, query)
  3. 然后驱动器的内容,在其回调中,一旦发现,检索文件。
  4. 工作完成!

下面给出了有关感兴趣的代码片段。

@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); 
    } 
}; 

感谢您的帮助!

+0

非常感谢。这个对我有用。我在这个问题上停留了两天。 :( – derjohng

卸载应用程序也会删除App文件夹中的数据。 This is from the REST API documentation,但我猜测同样的事情发生在Android和其他客户端API上。

+0

谢谢@adjuremods。但不完全。有关更多信息,请参阅我接受的答案。 –