在android中设置文件的完全权限
我使用以下代码设置android中文件的完全权限。 但它不起作用。我找不到原因。请帮忙在android中设置文件的完全权限,android,file,Android,File,我使用以下代码设置android中文件的完全权限。 但它不起作用。我找不到原因。请帮忙 File mypath=new File(directory, filename+ ".png"); Runtime.getRuntime().exec("chmod 777 " + mypath); System.out.println("FileExecute " + mypath.canExecute()); System.out.println("FileRead " + mypath.canRea
File mypath=new File(directory, filename+ ".png");
Runtime.getRuntime().exec("chmod 777 " + mypath);
System.out.println("FileExecute " + mypath.canExecute());
System.out.println("FileRead " + mypath.canRead());
System.out.println("FileWrite " + mypath.canWrite());
System.out.println("FileExists " + mypath.exists());
System.out.println("FileisFile " + mypath.isFile());
我得到的每个输出都是“false”。是否有其他方法来设置完全权限 如果exists()
输出为false,则表示文件不存在,因此您应该首先通过调用mypath.createNewFile()
创建它,然后重试:
if (file.exists())
{
file.setExecutable(boolean);
file.setReadable(boolean);
file.setWritable(boolean);
}
System.out.println(“FileisFile”+mypath.isFile());请注意,它也给出了false。但是目录和文件是正确的,请在文件资源管理器中检查您的文件。。