SOLVED ! Thx a lot !
There is a builtin function https://android.processing.org/reference/permissions/request.html
Here is my code
import android.os.Environment;
PImage img;
File myFile = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DCIM);
void setup() {
requestPermission("android.permission.READ_EXTERNAL_STORAGE", "initRead");
requestPermission("android.permission.WRITE_EXTERNAL_STORAGE", "initWrite");
}
void draw() {
}
void initRead(boolean granted) {
if (granted) {
println("init read sdcard OK");
String myPath= myFile.toString();
img = loadImage(myPath+"/cat.jpg");/// if needed add subfolders!
image(img,0,0);
// ...
} else {
println("Read SDcard is not available");
// ...
}
}
void initWrite(boolean granted) {
if (granted) {
println("init write sdcard OK");
// ...
} else {
println("Write SDcard is not available");
// ...
}
}