File System is a mess!

210 views
Skip to first unread message

Timur Talibayev

unread,
Mar 21, 2019, 11:21:54 AM3/21/19
to android-platform



A week ago I decided to create a simple File Manager as a part of
my edge panel app. I've seen that other edge panels that implemented a
feature like this didn't bother to make it as useful as it could be. I
thought it is a good chance for me. Boy was i wrong!

Took me a couple of hours to make java.io.File navigation integrated
into my app even with sd cards and USB OTG. Easy!
Onto the next thing - let's open our files via ACTION_VIEW intent in
outside apps:

Lets get a uri from a file. Uri.fromFile(myFile)! -> Nope! FileUriExposedException!

So, what do I do?! Smart people suggested to use FileProvider that
creates content:// Uris. Great now I will be able to open files from
my external storage and sd card!

Nope! There is no support for SD cards and using root-path (as some
suggested) is unsupported and unreliable. Oh and your Galaxy S8 with
android P won't be able to open files with write access in outside apps using FileProvider anyway. 
WHAT?!
Yep! You can download any file manager on the Play store that is using
FileProvider to create content URIs and none of them will be able to open image files in outside apps (like
Photos or your stock Gallery) with write access - you can watch the image, but you can't edit! 
Read any file manager reviews - they are full with frustrated users that have problems accessing their files.

Back to the drawing board and stackoverflow! After describing my problem smart people suggested to use 
Storage Access Framework, from the official docs:
Android 4.4 (API level 19) introduces the Storage Access Framework
(SAF). The SAF makes it simple for users to browse and open documents,
images, and other files across all of their preferred document storage
providers. A standard, easy-to-use UI lets users browse files
and access recents in a consistent way across apps and providers.


Great, sounds like a solution!
But not only it has a weird, not user friendly interface,

2vwls.png


even Google Drive doesn't support ACTION_OPEN_DOCUMENT_TREE. You
can only guide your users to pick one file at a time instead! 
Oh and even if you have the WRITE_EXTERNAL_STORAGE permission in your
manifest which user already permitted, you still need to send people
through that interface where they should try and select the external storage folder so you
can traverse the files!

The only thing devs using SAF for - is to get SD card/OTG access,
that is it, that is the only thing in the whole API
Here are some more SAF problems:
https://groups.google.com/d/msg/android-platform/Nyby3g_gGzk/sHMRPK5iFwAJ

In API 24 Google introduced StorageVolume API with createAccessIntent
which should make it easier for users to give permission to access
storage volumes. However you can't ask permissions to external storage root directory, only SD
card or common folders like Pictures, Downloads and etc. Why?

All this patches instead of one API that will cover each and every thing, turned file management coding into a nightmare.

I do understand that security is an important topic, but so does the usability. 
I think Google should stop making new OS versions every year and instead improve what they already created.
Cause with each new Android OS I feel that there are less and less apps that can be done. Custom lock screens for example 
are already things of the past. 


Reply all
Reply to author
Forward
0 new messages