嘿家伙我有问题我得到以下代码:
File folder = new File(Environment.getExternalStorageDirectory() + "/myapp/folderone/foldertwo"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { } else { }
但它根本不工作我还添加了权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
希望有人可以帮助我.
解决方法
尝试仅使用mkdirs()而不是mkdir(),这对我有用.
例:
File folder = new File(Environment.getExternalStorageDirectory() + "/myapp/folderone/foldertwo"); boolean success = false; if (!folder.exists()) { success = folder.mkdirs(); } if (!success) { } else { }