Reputation: 1051
i;m trying to create a folder in the android under the sdcard directory, here is my code
File folder = new File("/sdcard/"+ "testFolder");
if (!folder.exists())
{
folder.mkdirs();
Log.i("Sound folder", "Sound Folder created..");
}
else
{
Log.i("Sound folder", "Sound Folder already exists");
}
and i set the permission in the android manifest.xml, here it is :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
but when check for the folder i cant find it !! am i missing something
Upvotes: 0
Views: 57
Reputation: 14472
File
will not create the folder. Checkout mkDirs()
folder.mkDirs();
http://developer.android.com/reference/java/io/File.html#mkdirs()
You should not be using "/sdcard". Instead, use Environment.getExternalStorageDirectory()
File folder = new File(Environment.getExternalStorageDirectory() + "testFolder");
Upvotes: 1