Closed ahmedre closed 4 years ago
i actually did all 3 steps mentioned above in one go -
as of #1452, the default write directory for all new installations (or cleared data installations) is context.getExternalFilesDir
, which is the application specific directory that no longer needs special permissions to read or write.
moreover, on Android 29 and above, a migration happens whenever someone is using /sdcard
- the data is copied to context.getExternalFilesDir
and the old directory is removed. note that we opt out of scoped storage in Android 29 to make this possible.
(note that this is safe irrespective of someone having set a custom location - the reason is that as of api 19 and above, the only custom locations settable are those returned by getExternalFilesDirs
, which are all writeable without permissions on new apis and are safe to write to).
in sha' Allah after some time, we can target Android 30 with almost no additional changes (except for adding preserveLegacyExternalStorage
to the manifest and removing /sdcard
as an option from the advanced settings dialog).
note that, for now, i am keeping the /sdcard
option in advanced settings - this is to allow someone who copied the data from another device and then installed the app to be able to go to advanced settings, switch to the sdcard, and regain their data without re-downloading everything. in the future, however, this should be removed for api 30 and above in sha' Allah.
In preparation for the Storage Access Framework, Quran for Android should reconsider how it deals with files. This is required since we'll lose the ability to write to external storage (outside of our own data directory) in the next version (and, potentially, even on Android Q if we don't set the legacy storage flag).
Proposal:
/Android/data
directories.This will require a migration - people currently using
/sdcard/quran_android
need to be explicitly migrated to internal storage somehow - especially people on newer api versions that are either on Q now and/or are likely to get upgraded to the next version of Android.on launch, the app today requests sd card permissions - some initial thoughts are that perhaps the phases can be as follows:
/Android/data
. this only happens for fresh installs. if we can detect if this is a new install (i.e. nothing in shared prefs that are backed up to Google), perhaps don't even prompt./Android/data
and stop using the sdcard.