Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android:如何在android应用中从驱动器的应用文件夹中检索文件内容_Android - Fatal编程技术网

android:如何在android应用中从驱动器的应用文件夹中检索文件内容

android:如何在android应用中从驱动器的应用文件夹中检索文件内容,android,Android,我正在将一个文件上载到应用程序文件夹中。现在我卸载应用程序,然后再次安装,并试图检索应用程序文件夹内容,但我没有得到任何文件内容,logcat显示GoogleApiDrive连接失败,但再次按下按钮检索内容,我得到了数据。请,有谁能帮我解决卸载应用程序后第一次检索数据的问题,但我能检索数据吗 @Override public void onConnected(Bundle connectionHint) { super.onConnected(connectionHint

我正在将一个文件上载到应用程序文件夹中。现在我卸载应用程序,然后再次安装,并试图检索应用程序文件夹内容,但我没有得到任何文件内容,logcat显示GoogleApiDrive连接失败,但再次按下按钮检索内容,我得到了数据。请,有谁能帮我解决卸载应用程序后第一次检索数据的问题,但我能检索数据吗

@Override
    public void onConnected(Bundle connectionHint) {
        super.onConnected(connectionHint);

        //query for file name in drive
        query = new Query.Builder()
        .addFilter(Filters.eq(SearchableField.MIME_TYPE, "text/plain"))
        .addFilter(
                Filters.eq(SearchableField.TITLE, "appfolderdata"))
                .build();
        Drive.DriveApi.query(getGoogleApiClient(), query).setResultCallback(
                metadataCallback);

    }

    final private ResultCallback<MetadataBufferResult> metadataCallback = new ResultCallback<MetadataBufferResult>() {

        DriveId driveId;
        @Override
        public void onResult(MetadataBufferResult result) {
            if (!result.getStatus().isSuccess()) {
                showMessage("Problem while retrieving results");
                finish();
            }
            //get metadata if backup file is present in drive
            MetadataBuffer metadata = result.getMetadataBuffer();
            System.out.println();
            if (metadata.getCount() > 0) {
                System.out.println("metadata.getCount() is : " + metadata.getCount());
                driveId = metadata.get(0).getDriveId();
                System.out.println("meta data drive id is : " + driveId);
            }
            metadata.close();
            if(driveId != null){
                Drive.DriveApi.fetchDriveId(getGoogleApiClient(), driveId.getResourceId())
                .setResultCallback(idCallback);
            }else{
                if(count < 3){
                    Drive.DriveApi.query(getGoogleApiClient(), query).setResultCallback(
                            metadataCallback);
                    count++;
                }else{
                    showMessage("Problem while retrieving results");
                    if(dialog != null){
                        dialog.dismiss();
                    }
                    finish();
                }
            }
        }
    };
@覆盖
未连接的公共无效(捆绑连接提示){
super.onConnected(connectionHint);
//查询驱动器中的文件名
query=newquery.Builder()
.addFilter(Filters.eq(SearchableField.MIME_TYPE,“text/plain”))
.addFilter(
Filters.eq(SearchableField.TITLE,“appfolderdata”))
.build();
Drive.DriveApi.query(getGoogleAppClient(),query).setResultCallback(
元数据回调);
}
最终私有ResultCallback metadataCallback=新ResultCallback(){
DriveId-DriveId;
@凌驾
公共void onResult(MetadataBufferResult结果){
如果(!result.getStatus().issucess()){
showMessage(“检索结果时出现问题”);
完成();
}
//如果驱动器中存在备份文件,则获取元数据
MetadataBuffer metadata=result.getMetadataBuffer();
System.out.println();
如果(metadata.getCount()>0){
System.out.println(“metadata.getCount()是:”+metadata.getCount());
driveId=metadata.get(0.getDriveId();
System.out.println(“元数据驱动器id为:“+driveId”);
}
metadata.close();
if(driveId!=null){
Drive.DriveApi.fetchDriveId(getGoogleAppClient(),driveId.getResourceId())
.setResultCallback(idCallback);
}否则{
如果(计数<3){
Drive.DriveApi.query(getGoogleAppClient(),query).setResultCallback(
元数据回调);
计数++;
}否则{
showMessage(“检索结果时出现问题”);
如果(对话框!=null){
dialog.dismise();
}
完成();
}
}
}
};