This is my code.
File selfieLocation = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "Daily Selfies"); boolean isDirectory = false; if(!selfieLocation.isDirectory()) { //Creates directory named by this file selfieLocation.mkdir(); isDirectory = selfieLocation.isDirectory(); } //array of strings for(String selfiePath: selfieLocation.list()) { selfies.add(selfiePath); }
Basically, I am trying to create my own custom directory inside a standard directory where I can place images available to the user.
I looked at related topics and saw this one, Android: it was not possible to create a directory in the default folder with pictures . However, I made sure that I had a call to getExternal .... and not just the Environment.DIRECTORY_PICTURES parameter as the parameter. I also looked here http://developer.android.com/guide/topics/data/data-storage.html#filesExternal and saw that I have the correct call method / format to create a custom folder in external memory. Example docs:
File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), albumName); if (!file.mkdirs()) { Log.e(LOG_TAG, "Directory not created"); }
I went through my code and saw that the local variable isDirectory remained false even after calling selfieLocation.mkdir (). Does anyone know why this directory cannot be created?
source share