Android: how to get file content from app folder on disk in android app

I download the file to disk in the application folder. Now I uninstall the application and then install again and try to get the contents of the application folder, but I don't get any file contents and the logcat shows that the GoogleApiDrive connection failed, but then clicking the button again to get the contents, I get the data. Please can anyone help me decide how to get the data for the first time after uninstalling the application, but the email can I get the data?

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

      

+3


source to share





All Articles