My mobile cloud application gets all content from the remote server, and it should use Storage Access Framework http://developer.android.com/guide/topics/providers/document-provider.html and implement DocumentsProvider http://developer.android.com/reference/android/provider/DocumentsProvider.html to be displayed in third-party apps (like Microsoft Office) in list of apps which supported SAF on opening or saving. After opening file from SAF app and modifing it in third-party app (Microsof Office for example) this file should be overriden on the server, but I can not find corresponding method in SAF framework for this.
Now I see the only way to implement this:
Can you offer simpler way to achieve desired result? Or maybe you see some errors in my approach. The similar functionality is already implemented in dropbox app. Thanks!
openDocument() returns a ParcelFileDescriptor and if you use the ParcelFileDescriptor.open(File, int, Handler, OnCloseListener), then you'll get a callback to the OnCloseListener's onClose() - at that point, you know the external application has finished with the file and you can start a sync operation.
// A file representing the local copy of the file
File file = ...;
return ParcelFileDescriptor.open(
file,
ParcelFileDescriptor.parseMode(mode),
new Handler(), // use the current thread
onCloseListener);