简体   繁体   English

创建文件android时出错

[英]error creating file android

When I run the app on Nexus 5 there are no problem with the file but in another smartphone I have a problem, I think it could be the spaces and I deleted it. 当我在Nexus 5上运行该应用程序时,文件没有问题,但是在另一部智能手机中我遇到了问题,我认为可能是空格,因此我将其删除了。

The code is : 代码是:

    File file = new File(directory,new SimpleDateFormat("dd-MM-yyyy-HH:mm:ss",Locale.ROOT).format(new Date()).toString()+"-"+idUser+"-"+idTest+".txt");
    FileOutputStream outputStream = new FileOutputStream(file);

path file: /storage/sdcard0/Nexio/Tests/23-07-2014-16:33:11-alex-0.txt 路径文件:/ storage / sdcard0 / Nexio / Tests / 23-07-2014-16:33:11-alex-0.txt

The directory exists. 该目录存在。 And the exception is "FileNotFoundException" 例外是“ FileNotFoundException”

您可能正在使用静态字符串设置目录..那是我的猜测..使用http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM