Добавьте это в свой манифест
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
А затем запросите разрешения в приложении примерно так:
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if(requestCode == REQUEST_CAMERA){
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED){
try {
getImageFromCamera();
} catch (IOException e) {
e.printStackTrace();
}
}
else{
Toasty.error(getApplicationContext(), "Permission Needed.", Toast.LENGTH_LONG).show();
}
}
else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
if(requestCode == PICK_IMAGE){
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED){
getImageFromGallery();
}
else{
Toasty.error(getApplicationContext(), "Permission Needed.", Toast.LENGTH_LONG).show();
}
}
else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}