Try this
Use both WRITE_EXTERNAL_STORAGE
and WRITE_EXTERNAL_STORAGE
to read and write file
<uses-feature android:name="android.hardware.camera2" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Here ask to write permission & read permission add multiple permission
public void requestRuntimePermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(context,android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
}
}
}
Check this Android 6.0 multiple permissions
//Check permission granted or not if granted then call this block
Uri selectedImage = data.getData();
String[] filePaths = {MediaStore.Images.Media.DATA};
Cursor c = this.getContentResolver().query(selectedImage, filePaths, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePaths[0]);
filePath = c.getString(columnIndex);
c.close();