Friday, December 26, 2014

Update "android.permission.READ_EXTERNAL_STORAGE" for KitKat

With re-visiting my old post "Convert between Uri and file path, and load Bitmap from", to load image from Uri form "content://media/external/images/media/xxxxx", real path in form of "/storage/emulated/0/Picture/..." and Uri in form of "file:///storage/emulated/0/Picture/...".

When run on HTC One X of Android 4.2.2, it can read the image from all three form, "content://media/external/images/media/xxxxx", "/storage/sdcard0/Pictures/Screenshots/..." and "file:///storage/sdcard0/Pictures/Screenshots/...".

When run on Nexus 7 of Android 4.4.4 KitKat, only the first Uri form of "content://media/external/images/media/xxxxx" can be display, and nothing display on the other two; "/storage/emulated/0/Pictures/Screenshots/..." and "file:///storage/emulated/0/Pictures/Screenshots/...".

To fix it, add permission of "android.permission.READ_EXTERNAL_STORAGE" in AndroidManifest.xml. Refer to the video below.

No comments: