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
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.