我遇到了運行函數Mkdir()的問題。我該怎麼辦? 我已經添加讀/寫權限:Android中無法使用mkdir文件夾
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
下面是我的代碼片段:
private File getTempFile(Context context)
{
File path;
//Find the dir to save cached images
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)){
path=new File(android.os.Environment.getExternalStorageDirectory(),"/Tanker/Foto/");
}
else {
path=context.getCacheDir();
}
String pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg";
if (!path.exists())
{
path.mkdir();
}
return new File(path, pictureFileName);
}
請幫助。
試試這個'path.mkdirs();' – 2014-10-06 09:16:12