Search code examples
androidandroid-contentproviderandroid-contentresolver

How to validate android content provider/resolver succeeded in saving the file?


In my application I can read and save a file to a content provider.

When calling this code I assume the file was properly saved if no exceptions were thrown.

OutputStream outputStream = getContentResolver().openOutputStream(uri, "w");
// write to stream
outputStream.close();

But working with google drive I found out that this might not be true, for example if the user doesn't have an internet connection the file's upload is paused.

How can I know if the content provider hasn't applied the changes to the file?
Is there a way to retry uploading once I know the initial save failed?


Solution

  • it is impossible to know the content provider applied the changes to the file