Android:应用程序重新安装后找不到应用程序文件夹中的已上传文件 [英] Android: Uploaded file in App Folder not found after app reinstall
本文介绍了Android:应用程序重新安装后找不到应用程序文件夹中的已上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在应用程序中实施了Google云端硬盘备份。
我在应用程序文件夹
中上传备份。但是,在我重新安装我的应用程序后,它无法找到新创建的文件。
我有解决这个问题的任何解决方法吗?
谢谢。
解决方案
我做了以下工作:
- 我使用
requestSync(GoogleApiClient)
- 然后,在其回调函数中,我查询驱动使用
Drive.DriveApi.query(GoogleApiClient,query)
- 然后,在其回调中,如果找到,则检索文件。
- 完成任务!
@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 检索结果时出现问题);
return;
query = new Query.Builder()
.addFilter(Filters.and(Filters.eq(SearchableField.TITLE,title),
Filters.eq(SearchableField .TRASHED,false)))
.build();
Drive.DriveApi.query(getGoogleApiClient(),查询)
.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(检索结果时出现问题);
return;
}
MetadataBuffer mdb = result.getMetadataBuffer();
(元数据md:mdb){
日期createdDate = md.getCreatedDate();
DriveId driveId = md.getDriveId();
}
readFromDrive(driveId);
}
};
感谢您的帮助!
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.
解决方案
I did the following:
- I use
requestSync(GoogleApiClient)
- Then, in its callback, I query the contents of the drive using
Drive.DriveApi.query(GoogleApiClient, query)
- Then, in its callback, if found, retrieve the file.
- Job done!
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!
这篇关于Android:应用程序重新安装后找不到应用程序文件夹中的已上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文