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
android


source to share


No one has answered this question yet

Check out similar questions:

3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
2510
How to persist android activity state by persisting instance state?
1270
How to pass data between activities in an Android app?
1169
Is there a way to get the source code from the APK file?
1002
How do I display an alert dialog on Android?
964
Download file from Android and show progress in ProgressDialog
960
How to rotate the screen of Android emulator?
862
What are the "tools: context" in android layout files?
831
How to manage startActivityForResult on Android?
1
Create / Edit / Extract DB File with GDAA (Google Drive Api for Android)



All Articles
Loading...
X
Show
Funny
Dev
Pics