Yep, you're right that checking FLAG_SUPPORTS_WRITE is the best way to
check if a write is allowed.

If you're really looking to focus on writing data, then
ACTION_CREATE_DOCUMENT might be a better fit, since it also lets the user
select an existing file, and it filters to only allow selection of
documents that have FLAG_SUPPORTS_WRITE set.

I'm thinking that allowing an app to request filtering of read-only
documents during a OPEN_DOCUMENT request would lead to user confusion
because of the inconsistency between apps.  (For example, a user would
still expect to open a read-only document for viewing purposes.)  If a user
then tried saving changes to a read-only document, it makes sense for the
app to use CREATE_DOCUMENT to ask them to save the modifications somewhere
else.

Hope this helps.  :)

j


On Wed, Jan 1, 2014 at 9:05 PM, Dave Smith <[email protected]> wrote:

> As far as I can tell from the documentation and testing with the new
> Storage Access Framework and Intent.ACTION_OPEN_DOCUMENT, there doesn't
> seem to be a way (via an extra or otherwise) to pass with the Intent
> request to open a document to only return documents from providers that
> support writing (i.e. have FLAG_SUPPORTS_WRITE set).  Instead, we are
> forced to check a document selection made by the user (via a metadata
> query) to determine if the document supports write before we attempt to
> open an OutputStream or ParcelFileDescriptor in "w" mode.  Is this correct,
> or have I overlooked something?
>
> This seems to be a large missing piece in the new Storage Access Framework
> when attempting to allow a user to open an existing document to be edited
> as it forces the user to make a selection first, then have us check if they
> can write, throw and error if they cannot, and force them to pick again.
>  Furthermore, we cannot say that it is uncommon for documents providers not
> to support writing, because even the system media documents provider (i.e.
> the source for images/videos) does not support write and will throw and
> IllegalArgumentException ("Media is read-only") when one attempts to write
> to one of its files (as an image editing app, the most common example used
> in the docs, would attempt to do).  Is there a proper method with the new
> SAF of limiting selections to writable providers only?
>
> Feedback appreciated for anything I may have missed here.  As it stands,
> suggesting that developers use ACTION_OPEN_DOCUMENT for in-place editing
> doesn't seem like a viable approach.
>
> Dave Smith
> @devuwired
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jeff Sharkey
[email protected]

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to