I recently updated my app to Target API 29 (Android Q). It is a Photo app which takes pictures and stores images in Gallery. I get WRITE_EXTERNAL_STORAGE
permission to create folder in primary external storage through 'getExternalStoragePublicDirectory' and read images from the gallery. Since, the above method is deprecated and Google recommends three options and i chose Mediastore.
Since we don't need write permission to store images anymore, i stopped asking write permission from the user when taking picture. But to read the images, we need permission. As per this table, Google recommends getting either WRITE_EXTERNAL_STORAGE
or READ_EXTERNAL_STORAGE
.
Ref: https://developer.android.com/training/data-storage
It also says that "For other apps to access your file, though the other app needs the READ_EXTERNAL_STORAGE permission"
And this recommendation in Android doc, https://developer.android.com/training/data-storage/shared/documents-files
“If your app uses the media store, however, you must request the READ_EXTERNAL_STORAGE permission to access other apps’ media files.”
I tested with my existing WRITE_EXTERNAL_STORAGE
permission and i was able to read images from gallery. But from the above recommendations, i feel that it is better I should go for READ_EXTERNAL_STORAGE
which gives more finer permission control.
Which one would be more appropriate?
Android updated their docs to use only read external storage while accessing images. Here is the reference https://developer.android.com/training/data-storage/use-cases