且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

机器人如何检查文件是否存在,否则创建一个?

更新时间:2023-11-28 10:07:22

请问路径/ SD卡/应用程序的名字'存在吗?您检查的文件,你检查的子目录应用程序的名字'之前。您需要检查是否存在您试图访问一个文件里面了。

Does the path '/sdcard/appname' exist? You check for the file before you check for the sub-directory 'appname'. You need to check if that exists before you try to access a file inside it.

此外,如果你只需要在文件读写的应用程序的数据,为什么不只是去与内部存储 - 少了一个明显的权限:) - >的这里的内部存储读取

Also if you simply need the file to read-write application data why not just go with internal storage - one less manifest permission :) -> read here for internal storage