I'm trying to make a folder in internal storage (where the user can access the folder) in Android Studio (if the folder is created, I don't want to create it again).
I've seen that link: Android create folders in Internal Memory, but here it doesn't shows what I want. I want the data to be accessible for the user, I don't want to store it here /data/data/package.name/app_MyDirName, for example.
I've tried that code but there is always a problem running it:
public void createFolder(View v){
File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "YOUR_FOLDER_NAME_HERE");
if (!folder.exists()) {
if(folder.mkdirs()){
Log.d("App","file created successfully");
}else{
Log.d("App","error creating folder");
}
}else{
Log.d("App","folder exists");
}
}
Here it's the output of the logcat:
2020-12-26 17:56:17.433 5981-5981/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2020-12-26 17:56:17.434 5981-5981/? E/Zygote: accessInfo : 1
2020-12-26 17:56:17.508 5981-5981/? E/mple.pruebadoc: Unknown bits set in runtime_flags: 0x8000
2020-12-26 17:56:18.878 5981-9037/com.example.pruebadocs E/gralloc: Arm Module v1.0
2020-12-26 17:56:18.879 5981-9037/com.example.pruebadocs E/ion: ioctl c0044901 failed with code -1: Invalid argument
I always receive the "error creating folder message", but I don't have any idea why.