Open ahmedre opened 7 years ago
I don't understand how putting "freeform custom folder location" solves issue with WRITE_EXTERNAL_STORAGE
permission.
you're right, it doesn't - but it's part of the fix so that we can remove all the hacky code that's trying to read the mounts and vold file and still support writing wherever for people who grant permissions (until one day, it's no longer possible, then we just set a maximum sdk on it).
The Problem
Historically, Quran has written to
/sdcard/quran_android
using theWRITE_EXTERNAL_STORAGE
permission. In KitKat, the first signs of the fact that this wasn't Google's preference started appearing, with the permission no longer being needed to write to the app's own directory in/sdcard/Android/data
. Marshmallow further madeWRITE_EXTERNAL_STORAGE
a dangerous permission, and there are many rumors that the days of this permission working are very limited.Today
The current state of the world is as follows:
/sdcard/quran_android
/sdcard/quran_android
, otherwise, we write togetExternalFilesDir()
(which is/sdcard/Android/data
).In addition, there's an "advanced setting" that lets the person customize the partition where we store data. The list of partitions is added via
getExternalFilesDirs
on KitKat and above, and by some hacks (reading/proc/mounts
and/system/etc/vold.fstab
files) on older versions.Ideally, we should simplify things and prefer for people to store within the app's data directory moving forward.
Considerations
Points to keep in mind:
a long long time ago, we did use
getExternalFilesDir
to store data, but people complained that they were losing their pages whenever they'd update the app. If this is true, hopefully this is fixed now, since we last tried this as the only option a really long time ago.using
getExternalFilesDir
prevents sharing of data files on multi-user devices due to sandboxing.people who upgrade from Lollipop to Marshmallow may be upset at "losing their data" if we decide to just write to
getExternalFilesDirs
.people often want to explicitly set a directory to use for Quran's files.
Proposed Solution
/sdcard/quran_android
.getExternalFilesDir
, and perhaps add a small button with "Advanced" that would then take them to the setting in point 4 below.getExternalFilesDir
, but can be modified by the person using the app).Thoughts?