[英]Nexus 6 Environment.getExternalStorageDirectory() cannot create directory External storage
I have a Nexus 6(Google Fi) I got an app that works on all other devices I tested but not on this one.我有一个 Nexus 6(Google Fi) 我有一个应用程序可以在我测试过的所有其他设备上运行,但不能在这个设备上运行。 Trying to create a directory or a file under this GetExternalStorageDirectory() is not working;尝试在此 GetExternalStorageDirectory() 下创建目录或文件不起作用; I have tried mkdirs() as well.我也试过 mkdirs() 。 I cannot see the emulated/0 folder from my FileExplorer(on the phone) or from my PC(W10).我无法从我的 FileExplorer(在手机上)或我的 PC(W10)中看到 emulated/0 文件夹。 And yes I do have the manifest permission for writing files.是的,我确实拥有写入文件的清单权限。 Using the following...使用以下...
---Definition
public static String currentdirectory=Environment.getExternalStorageDirectory() + "/ADAK";
---Code snipplet
sd = new File(G.currentdirectory);
if (!sd.exists() && !sd.isDirectory()) {
if (!sd.mkdir()) {
G.WTL("Cannot create ADAK directory");
G.WTS(this, "Cannot create ADAK directory");
System.exit(0);
}
}
Android 6.0 Marshmallow using API 23 have a new requirement, permissions must be requested each time the application starts.使用 API 23 的 Android 6.0 Marshmallow 有一个新要求,每次应用程序启动时都必须请求权限。 All of this is well documented by Google.所有这些都被 Google 很好地记录在案。 http://developer.android.com/training/permissions/requesting.html http://developer.android.com/training/permissions/requesting.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.