I am creating a gallery app using a tutorial but get the following error:
abc directory path is not valid! Please set the image directory name AppConstant.java c
Here's how you create directories if they don't exist. Considering that directory
is indeed a directory.
// If the parent dir doesn't exist, create it
if (!directory.exists()) {
if (parentDir.mkdirs()) {
Log.d(TAG, "Successfully created the parent dir:" + parentDir.getName());
} else {
Log.d(TAG, "Failed to create the parent dir:" + parentDir.getName());
}
}
mkdirs()
will also create missing parent directories (i.e. all directories that lead to directory
).